function uc_taxes_javascript in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_taxes/uc_taxes.module \uc_taxes_javascript()
AJAX callback for order preview.
Calculate tax amounts for an order in the payment checkout pane.
1 string reference to 'uc_taxes_javascript'
- uc_taxes_menu in uc_taxes/
uc_taxes.module - Implementation of hook_menu().
File
- uc_taxes/
uc_taxes.module, line 502
Code
function uc_taxes_javascript() {
drupal_set_header("Content-Type: text/javascript; charset=utf-8");
$order = $_POST['order'];
if ($order = unserialize(rawurldecode($order))) {
$taxes = module_invoke_all('calculate_tax', $order);
$subtotal = uc_line_item_tax_subtotal('load', $order);
if (is_array($subtotal) && !empty($taxes)) {
$taxes['subtotal'] = array(
'id' => 'subtotal',
'name' => $subtotal[0]['title'],
'amount' => $subtotal[0]['amount'],
'weight' => -10,
);
}
//drupal_set_message('<pre>'. print_r($taxes, true) .'</pre>');
if (count($taxes)) {
print drupal_to_js((array) $taxes);
}
else {
print '{}';
}
}
else {
print '{}';
}
exit;
}