You are here

function uc_shipping_address_form in Ubercart 5

Same name and namespace in other branches
  1. 6.2 shipping/uc_shipping/uc_shipping.module \uc_shipping_address_form()
  2. 7.3 shipping/uc_shipping/uc_shipping.module \uc_shipping_address_form()
2 calls to uc_shipping_address_form()
uc_shipping_shipment_edit in shipping/uc_shipping/uc_shipping.module
Create or edit a shipment.
uc_ups_fulfill_order in shipping/uc_ups/uc_ups.module
Shipment creation callback.

File

shipping/uc_shipping/uc_shipping.module, line 1387
Organizes ordered products into packages and sets them up for shipment. Shipping method modules may add functionality to generate shipping labels and tracking numbers.

Code

function uc_shipping_address_form($addresses, $order) {
  uc_add_js(drupal_get_path('module', 'uc_shipping') . '/uc_shipping.js');
  $form = array();
  $form['origin'] = array(
    '#type' => 'fieldset',
    '#title' => t('Origin address'),
    '#collapsible' => true,
    '#collapsed' => false,
    '#weight' => -2,
    '#theme' => 'uc_shipping_address',
  );
  $address = reset($addresses);
  $form['origin']['pickup_address_select'] = uc_shipping_select_address($addresses, 'apply_address(\'pickup\', this.value);', t('Saved Addresses'), TRUE);
  $form['origin']['pickup_address_select']['#weight'] = -2;
  $form['origin']['pickup_email'] = uc_textfield(uc_get_field_name('email'), variable_get('uc_store_email', null), FALSE);
  $form['origin']['pickup_email']['#weight'] = -1;
  $form['origin']['pickup_first_name'] = uc_textfield(uc_get_field_name('first_name'), $address->first_name, FALSE);
  $form['origin']['pickup_last_name'] = uc_textfield(uc_get_field_name('last_name'), $address->last_name, FALSE);
  $form['origin']['pickup_phone'] = uc_textfield(uc_get_field_name('phone'), variable_get('uc_store_phone', null), FALSE, NULL, 32, 16);
  $form['origin']['pickup_company'] = uc_textfield(uc_get_field_name('company'), $address->company, FALSE);
  $form['origin']['pickup_street1'] = uc_textfield(uc_get_field_name('street1'), $address->street1, FALSE, NULL, 64);
  $form['origin']['pickup_street2'] = uc_textfield(uc_get_field_name('street2'), $address->street2, FALSE, NULL, 64);
  $form['origin']['pickup_city'] = uc_textfield(uc_get_field_name('city'), $address->city, FALSE);
  $form['origin']['pickup_country'] = uc_country_select(uc_get_field_name('country'), $address->country);
  if (isset($_POST['pickup_country'])) {
    $country = $_POST['pickup_country'];
  }
  else {
    $country = $address->country;
  }
  $form['origin']['pickup_zone'] = uc_zone_select(uc_get_field_name('zone'), $address->zone, null, $country);
  $form['origin']['pickup_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $address->postal_code, FALSE, NULL, 10, 10);
  $order_form = uc_order_pane_ship_to('edit-form', $order);
  $form['destination'] = $order_form['ship_to'];
  $form['destination']['delivery_email'] = uc_textfield(uc_get_field_name('email'), $order->primary_email, FALSE);
  $form['destination']['delivery_email']['#weight'] = -1;
  $form['destination']['#title'] = t('Destination Address');
  $form['destination']['#collapsible'] = true;
  $form['destination']['#weight'] = -1;
  $form['destination']['#theme'] = 'uc_shipping_address';
  return $form;
}