You are here

function uc_taxes_uc_calculate_tax in Ubercart 7.3

Calculates the amount and types of taxes that apply to an order.

File

uc_taxes/uc_taxes.module, line 535
Ubercart Taxes module.

Code

function uc_taxes_uc_calculate_tax($order) {
  if (!is_object($order)) {
    return array();
  }
  if (empty($order->delivery_postal_code)) {
    $order->delivery_postal_code = $order->billing_postal_code;
  }
  if (empty($order->delivery_zone)) {
    $order->delivery_zone = $order->billing_zone;
  }
  if (empty($order->delivery_country)) {
    $order->delivery_country = $order->billing_country;
  }
  $order->taxes = array();
  foreach (uc_taxes_filter_rates($order) as $tax) {
    if ($line_item = uc_taxes_apply_tax($order, $tax)) {
      $order->taxes[$line_item->id] = $line_item;
    }
  }
  return $order->taxes;
}