You are here

function uc_taxes_javascript in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_taxes/uc_taxes.module \uc_taxes_javascript()

AJAX callback for order preview.

Calculates 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
Implements hook_menu().

File

uc_taxes/uc_taxes.module, line 468

Code

function uc_taxes_javascript() {
  $order = $_POST['order'];
  if ($order = unserialize(rawurldecode($order))) {
    $taxes = module_invoke_all('calculate_tax', $order);
    $callback = _line_item_data('tax_subtotal', 'callback');
    if (function_exists($callback)) {
      $subtotal = $callback('load', $order);
      if (is_array($subtotal) && !empty($taxes)) {
        $taxes['subtotal'] = (object) array(
          'id' => 'subtotal',
          'name' => $subtotal[0]['title'],
          'amount' => $subtotal[0]['amount'],
          'weight' => -10,
          'summed' => 0,
        );
      }
    }
  }
  drupal_json((array) $taxes);
}