function uc_tax_uc_calculate_tax in Ubercart 8.4
Calculates the amount and types of taxes that apply to an order.
Parameters
\Drupal\uc_order\OrderInterface $order: The full order object for the order want to calculate taxes for.
File
- uc_tax/
uc_tax.module, line 415 - Ubercart Tax module.
Code
function uc_tax_uc_calculate_tax(OrderInterface $order) {
if (!is_object($order)) {
return [];
}
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->tax = [];
foreach (uc_tax_filter_rates($order) as $tax) {
if ($line_item = uc_tax_apply_tax($order, $tax)) {
$order->tax[$line_item->id] = $line_item;
}
}
return $order->tax;
}