You are here

function uc_line_items_calculate in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_order/uc_order_line_item.inc \uc_line_items_calculate()
  2. 7.3 uc_order/uc_order.line_item.inc \uc_line_items_calculate()

Calculates the total value of line items of types that should be calculated.

1 call to uc_line_items_calculate()
uc_order_get_total in uc_order/uc_order.module
Calculate up an order's total!

File

uc_order/uc_order.line_item.inc, line 88
This file contains the callbacks for the default line items for orders and the various functions that make line items work.

Code

function uc_line_items_calculate($order) {
  $total = 0;
  $context = array(
    'revision' => 'altered',
    'type' => 'line_item',
    'subject' => array(
      'order' => $order,
    ),
  );
  if (isset($order->line_items) && is_array($order->line_items)) {
    foreach ($order->line_items as $item) {
      $context['subject']['line_item'] = $item;
      if (_line_item_data($item['type'], 'calculated') == TRUE) {
        $total += uc_price($item['amount'], $context);
      }
    }
  }
  return $total;
}