function uc_global_quote_admin in Ubercart Global Quote 6
Same name and namespace in other branches
- 7 uc_global_quote_admin.inc \uc_global_quote_admin()
Configures the store shipping rates
1 string reference to 'uc_global_quote_admin'
- uc_global_quote_menu in ./
uc_global_quote.module - Implementation of hook_menu().
File
- ./
uc_global_quote_admin.inc, line 10 - Administration pages for global quotes
Code
function uc_global_quote_admin($form_state, $id = 0) {
$form = array();
$form['rates'] = array(
'#tree' => TRUE,
);
if ($id) {
$label = 'Edit quote';
}
else {
$label = 'Add a new quote';
$edit->id = NULL;
$edit->qid = NULL;
$edit->min = 0;
$edit->max = 0;
$edit->rate = 0.0;
$edit->type = NULL;
}
$result = db_query("SELECT * FROM {uc_global_quote}");
while ($r = db_fetch_object($result)) {
$qid = $r->qid;
$form['rates'][$qid]['delete'] = array(
'#type' => 'checkbox',
'#default_value' => 0,
);
if ($id && $id == $qid) {
$edit = $r;
}
}
// Get zones
$zones = uc_shipping_zones_get_select();
$form['quote'] = array(
'#type' => 'fieldset',
'#title' => t($label),
'#description' => t('Defines a range of weights for the order total weight.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['quote']['qid'] = array(
'#type' => 'hidden',
'#value' => $edit->qid,
);
$form['quote']['uc_global_quote_minimum'] = array(
'#type' => 'textfield',
'#title' => t('Minimum weight'),
'#default_value' => number_format($edit->min, 2, '.', ''),
'#size' => 12,
'#description' => t('minimum order weight in %unit', array(
'%unit' => variable_get('uc_weight_unit', 'lb'),
)),
);
$form['quote']['uc_global_quote_maximum'] = array(
'#type' => 'textfield',
'#title' => t('Maximum weight'),
'#default_value' => number_format($edit->max, 2, '.', ''),
'#size' => 12,
'#description' => t('maximum order weight in %unit', array(
'%unit' => variable_get('uc_weight_unit', 'lb'),
)),
);
$form['quote']['uc_global_quote_rate'] = array(
'#type' => 'textfield',
'#title' => t('Shipping Rate'),
'#default_value' => number_format($edit->rate, variable_get('uc_currency_prec', 2), '.', ''),
'#size' => 12,
'#description' => t('Shipping price in %currency', array(
'%currency' => variable_get('uc_currency_code', 'USD'),
)),
);
$form['quote']['uc_global_quote_zone'] = array(
'#type' => 'select',
'#title' => t('Shipping zone'),
'#options' => $zones,
'#default_value' => $edit->zid,
'#multiple' => FALSE,
'#description' => t('Select a zone for this rate. ') . l('edit/add zones', 'admin/store/settings/quotes/methods/zones'),
);
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Changes'),
);
$form['#redirect'] = 'admin/store/settings/quotes/methods/global_quote';
return $form;
}