You are here

function uc_store_js_util in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_store_js_util()

A handler for Javascript helper functions...

1 string reference to 'uc_store_js_util'
uc_store_menu in uc_store/uc_store.module
Implementation of hook_menu().

File

uc_store/uc_store.module, line 1744
Contains global Ubercart functions and store administration functionality.

Code

function uc_store_js_util($func) {
  switch ($func) {
    case 'currency_format':
      $amount = is_numeric($_POST['amount']) ? $_POST['amount'] : 0;
      $output = uc_currency_format($amount);
      break;
    case 'zone_select':
      $country_id = intval($_POST['country_id']) > 0 ? intval($_POST['country_id']) : uc_store_default_country();
      $title = isset($_POST['title']) ? check_plain($_POST['title']) : NULL;
      $display = isset($_POST['display']) ? check_plain($_POST['display']) : 'name';
      $select = uc_zone_select($title, NULL, NULL, $country_id, $display);
      $select['#parents'] = array();
      $match = array(
        '`<[/]*div[^>]*>`',
        '`<[/]*select[^>]*>`',
        '`\\n|\\r`',
      );
      $replace = array(
        '',
        '',
        '',
      );
      $output = preg_replace($match, $replace, theme('select', $select));
  }
  print $output;
  exit;
}