You are here

function uc_usps_form_alter in Ubercart 5

Same name and namespace in other branches
  1. 6.2 shipping/uc_usps/uc_usps.module \uc_usps_form_alter()
  2. 7.3 shipping/uc_usps/uc_usps.module \uc_usps_form_alter()

Implementation of hook_form_alter().

Add package type to products.

See also

uc_product_form

File

shipping/uc_usps/uc_usps.module, line 41
Shipping quote method module that receives quotes from the United States Postal Service via XML web service.

Code

function uc_usps_form_alter($form_id, &$form) {
  $node = $form['#node'];
  if (is_object($node) && $form_id == $node->type . '_node_form' && isset($form['base']['dimensions']) && in_array($node->type, module_invoke_all('product_types'))) {
    $enabled = variable_get('uc_quote_enabled', array());
    $weight = variable_get('uc_quote_method_weight', array(
      'usps' => 0,
      'usps_intl' => 1,
    ));
    $form['shipping']['usps'] = array(
      '#type' => 'fieldset',
      '#title' => t('USPS product description'),
      '#collapsible' => true,
      '#collapsed' => $enabled['usps'] == false || uc_product_get_shipping_type($node) != 'small_package',
      '#weight' => $weight['usps'],
      '#tree' => true,
    );
    $form['shipping']['usps']['container'] = array(
      '#type' => 'select',
      '#title' => t('Package type'),
      '#options' => _uc_usps_pkg_types(),
      '#default_value' => $node->usps['container'] ? $node->usps['container'] : 'RECTANGULAR',
    );
  }
}