function uc_line_item_tax_subtotal in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_taxes/uc_taxes.module \uc_line_item_tax_subtotal()
- 7.3 uc_taxes/uc_taxes.module \uc_line_item_tax_subtotal()
Handles the line item subtotal before taxes.
1 string reference to 'uc_line_item_tax_subtotal'
- uc_taxes_line_item in uc_taxes/
uc_taxes.module - Implements hook_line_item().
File
- uc_taxes/
uc_taxes.module, line 241
Code
function uc_line_item_tax_subtotal($op, $order) {
$amount = 0;
$has_taxes = FALSE;
$different = FALSE;
if (is_array($order->products)) {
foreach ($order->products as $item) {
$amount += $item->price * $item->qty;
}
}
if (is_array($order->line_items)) {
foreach ($order->line_items as $key => $line_item) {
if ($line_item['type'] == 'subtotal') {
continue;
}
if (substr($line_item['type'], 0, 3) != 'tax') {
$amount += $line_item['amount'];
$different = TRUE;
}
else {
$has_taxes = TRUE;
}
}
}
if (isset($order->taxes) && is_array($order->taxes)) {
$has_taxes = TRUE;
}
if ($different && $has_taxes) {
switch ($op) {
case 'cart-preview':
drupal_add_js("if (Drupal.jsEnabled) { \$(document).ready(function() {\n if (window.set_line_item) {\n set_line_item('tax_subtotal', '" . t('Subtotal excluding taxes') . "', " . $amount . ", " . variable_get('uc_li_tax_subtotal_weight', 8) . ");\n }\n })};", 'inline');
break;
case 'load':
return array(
array(
'id' => 'tax_subtotal',
'title' => t('Subtotal excluding taxes'),
'amount' => $amount,
'weight' => variable_get('uc_li_tax_subtotal_weight', 7),
),
);
}
}
}