You are here

function uc_order_get_total in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_order/uc_order.module \uc_order_get_total()
  2. 7.3 uc_order/uc_order.module \uc_order_get_total()

Calculate up an order's total!

10 calls to uc_order_get_total()
theme_uc_payment_totals in payment/uc_payment/uc_payment.module
Generates markup for payment totals.
UbercartCartCheckoutTestCase::createOrder in uc_cart/uc_cart.test
Creates a new order.
UbercartCreditCardTestCase::createOrder in payment/uc_credit/uc_credit.test
Helper function. Creates a new order.
uc_cart_checkout_form_validate in uc_cart/uc_cart.pages.inc
Form validation for uc_cart_checkout_form().
uc_line_item_subtotal in uc_order/uc_order.line_item.inc
Handles the subtotal line item.

... See full list

File

uc_order/uc_order.module, line 1508

Code

function uc_order_get_total($order, $products_only = FALSE) {
  $total = 0;
  if ($order === FALSE) {
    return $total;
  }
  if (isset($order->products) && is_array($order->products)) {
    $context = array(
      'revision' => 'altered',
      'type' => 'order_product',
    );
    foreach ($order->products as $product) {
      $price_info = array(
        'price' => $product->price,
        'qty' => $product->qty ? $product->qty : 1,
      );
      $context['subject'] = array(
        'order' => $order,
        'product' => $product,
        'node' => node_load($product->nid),
      );
      $total += uc_price($price_info, $context);
    }
  }
  if ($products_only) {
    return $total;
  }
  $total += uc_line_items_calculate($order);
  foreach (module_list() as $module) {
    $function = $module . '_order';

    // $order must be passed by reference. Since hook_order() may be
    // unknowingly implemented (see date_order() in date_api.module), we verify
    // the results are numeric before continuing.
    if (function_exists($function) && ($value = $function('total', $order, NULL)) && is_numeric($value)) {
      $total += $value;
    }
  }
  return $total;
}