You are here

function uc_quote_method_settings in Ubercart 5

Same name and namespace in other branches
  1. 6.2 shipping/uc_quote/uc_quote.admin.inc \uc_quote_method_settings()
  2. 7.3 shipping/uc_quote/uc_quote.admin.inc \uc_quote_method_settings()

Settings for the shipping quote methods.

Enable and reorder shipping quote methods. Set the default shipping type.

See also

theme_uc_quote_method_settings

uc_quote_method_settings_validate

uc_quote_method_settings_submit

1 string reference to 'uc_quote_method_settings'
uc_quote_menu in shipping/uc_quote/uc_quote.module
Implementation of hook_menu().

File

shipping/uc_quote/uc_quote.module, line 749
The controller module for fulfillment modules that process physical goods.

Code

function uc_quote_method_settings() {
  $form = array();
  $form['methods'] = array(
    '#tree' => true,
  );
  $enabled = variable_get('uc_quote_enabled', array());
  $weight = variable_get('uc_quote_method_weight', array());
  $methods = uc_quote_shipping_method_options();
  if (is_array($methods)) {
    foreach ($methods as $id => $title) {
      $form['methods'][$id]['uc_quote_enabled'] = array(
        '#type' => 'checkbox',
        '#default_value' => $enabled[$id],
      );
      $form['methods'][$id]['uc_quote_method_weight'] = array(
        '#type' => 'weight',
        '#delta' => 5,
        '#default_value' => $weight[$id],
      );
    }
  }
  $shipping_types = uc_quote_shipping_type_options();
  if (is_array($shipping_types)) {
    $form['uc_quote_type_weight'] = array(
      '#type' => 'fieldset',
      '#title' => t('Type ordering'),
      '#description' => t('Determines which shipping methods are quoted at checkout when products of different shipping types are ordered. Lighter weights are chosen first.'),
      '#collapsible' => true,
      '#tree' => true,
    );
    $weight = variable_get('uc_quote_type_weight', array());
    $shipping_methods = module_invoke_all('shipping_method');
    $method_types = array();
    foreach ($shipping_methods as $method) {
      $method_types[$method['quote']['type']][] = $method['title'];
    }
    if (is_array($method_types['order'])) {
      $form['uc_quote_type_weight']['#description'] .= t('<br />The %list methods are compatible with any shipping type.', array(
        '%list' => implode(', ', $method_types['order']),
      ));
    }
    foreach ($shipping_types as $id => $title) {
      $form['uc_quote_type_weight'][$id] = array(
        '#type' => 'weight',
        '#title' => $title . (is_array($method_types[$id]) ? ' (' . implode(', ', $method_types[$id]) . ')' : ''),
        '#delta' => 5,
        '#default_value' => $weight[$id],
      );
    }
  }
  $form['uc_store_shipping_type'] = array(
    '#type' => 'select',
    '#title' => t('Default order fulfillment type for products'),
    '#options' => $shipping_types,
    '#default_value' => variable_get('uc_store_shipping_type', 'small_package'),
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}