function uc_ups_form_alter in Ubercart 6.2
Same name and namespace in other branches
- 5 shipping/uc_ups/uc_ups.module \uc_ups_form_alter()
- 7.3 shipping/uc_ups/uc_ups.module \uc_ups_form_alter()
Implements hook_form_alter().
Adds package type to products.
See also
uc_ups_product_alter_validate()
File
- shipping/
uc_ups/ uc_ups.module, line 113 - Shipping quote module that interfaces with www.ups.com to get rates for small package shipments.
Code
function uc_ups_form_alter(&$form, $form_state, $form_id) {
if (uc_product_is_product_form($form)) {
$node = $form['#node'];
$enabled = variable_get('uc_quote_enabled', array());
$weight = variable_get('uc_quote_method_weight', array(
'ups' => 0,
));
$ups = array(
'#type' => 'fieldset',
'#title' => t('UPS product description'),
'#collapsible' => TRUE,
'#collapsed' => $enabled['ups'] == FALSE || uc_product_get_shipping_type($node) != 'small_package',
'#weight' => $weight['ups'],
'#tree' => TRUE,
);
$ups['pkg_type'] = array(
'#type' => 'select',
'#title' => t('Package type'),
'#options' => _uc_ups_pkg_types(),
'#default_value' => isset($node->ups['pkg_type']) ? $node->ups['pkg_type'] : variable_get('uc_ups_pkg_type', '02'),
);
$form['shipping']['ups'] = $ups;
if ($enabled['ups']) {
$form['#validate'][] = 'uc_ups_product_alter_validate';
}
}
}