You are here

function merci_commerce_line_item_populate in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

1 call to merci_commerce_line_item_populate()
merci_commerce_line_item_add_form_submit in merci_commerce/merci_commerce.module

File

merci_commerce/merci_commerce.module, line 172

Code

function merci_commerce_line_item_populate(&$line_item, $product, $merci_line_item) {
  $merci_line_item_wrapper = entity_metadata_wrapper('merci_line_item', $merci_line_item);
  $line_item->data['merci_line_item_id'] = $merci_line_item_wrapper
    ->getIdentifier();
  $resource_wrapper = $merci_line_item_wrapper->{MERCI_RESOURCE_DISPLAY};
  switch ($product->sku) {
    case 'late_fee':
      $field_late_fine = $resource_wrapper->field_late_fine
        ->value();
      $product->commerce_price = empty($field_late_fine['amount']) ? $product->commerce_price : $resource_wrapper
        ->value()->field_late_fine;
      break;
    case 'replacement_fee':
      $field_replacement_cost = $resource_wrapper->field_replacement_cost
        ->value();
      $product->commerce_price = is_null($field_replacement_cost['amount']) ? $product->commerce_price : $resource_wrapper
        ->value()->field_replacement_cost;
      break;
    default:
      break;
  }
  commerce_product_line_item_populate($line_item, $product);
}