You are here

function uc_zone_select in Ubercart 5

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

Create a zone select box for a form. $display can be 'code' or 'name'.

11 calls to uc_zone_select()
uc_cart_pane_quotes in shipping/uc_quote/uc_quote.module
Cart pane callback.
uc_checkout_pane_billing in uc_cart/uc_cart_checkout_pane.inc
Get the billing information.
uc_checkout_pane_delivery in uc_cart/uc_cart_checkout_pane.inc
Get the delivery information.
uc_order_pane_bill_to in uc_order/uc_order_order_pane.inc
Handle the "Bill to" order pane.
uc_order_pane_ship_to in uc_order/uc_order_order_pane.inc
Handle the "Ship to" order pane.

... See full list

File

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

Code

function uc_zone_select($title, $default = NULL, $description = NULL, $country_id = NULL, $display = 'name', $required = FALSE) {
  if (empty($country_id)) {
    $country_id = uc_store_default_country();
  }
  $result = db_query("SELECT * FROM {uc_zones} WHERE zone_country_id = %d ORDER BY %s", $country_id, $display == 'code' ? 'zone_code' : 'zone_name');
  if (db_num_rows($result) == 0) {
    $options[-1] = t('Not applicable');
  }
  else {
    $options[''] = t('Please select');
    while ($zone = db_fetch_object($result)) {
      $options[$zone->zone_id] = $display == 'code' ? $zone->zone_code : $zone->zone_name;
    }
  }
  $select = array(
    '#type' => 'select',
    '#title' => $title,
    '#description' => $description,
    '#options' => $options,
    '#default_value' => $default,
    '#required' => $required,
    '#disabled' => isset($options[-1]) ? TRUE : FALSE,
    '#suffix' => '<span class="zone-throbber"></span>',
  );
  return $select;
}