You are here

function uc_zone_select in Ubercart 6.2

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

Creates a zone select box for a form.

Parameters

$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
Gets the billing information.
uc_checkout_pane_delivery in uc_cart/uc_cart_checkout_pane.inc
Gets the delivery information.
uc_order_pane_bill_to in uc_order/uc_order.order_pane.inc
Handles the "Bill to" order pane.
uc_order_pane_ship_to in uc_order/uc_order.order_pane.inc
Handles the "Ship to" order pane.

... See full list

File

uc_store/uc_store.module, line 1285
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');
  $options[''] = t('Please select');
  while ($zone = db_fetch_object($result)) {
    $options[$zone->zone_id] = $display == 'code' ? $zone->zone_code : $zone->zone_name;
  }
  if (count($options) == 1) {
    $options = array(
      -1 => t('Not applicable'),
    );
  }
  $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;
}