'value', '#value' => $order->order_id);
$packages = array();
$addresses = array();
// Container for package data
$form['packages'] = array(
'#type' => 'fieldset',
'#title' => t('Packages'),
'#collapsible' => TRUE,
'#tree' => TRUE,
);
foreach ($package_ids as $id) {
$package = uc_shipping_package_load($id);
if ($package) {
foreach ($package->addresses as $address) {
if (!in_array($address, $addresses)) {
$addresses[] = $address;
}
}
// Create list of products and get a representative product (last one in
// the loop) to use for some default values.
$product_list = array();
$declared_value = 0;
foreach ($package->products as $product) {
$product_list[] = $product->qty . ' x ' . $product->model;
$declared_value += $product->qty * $product->price;
}
// Use last product in package to determine package type.
$ups_data = db_query("SELECT pkg_type FROM {uc_ups_products} WHERE nid = :nid", array(':nid' => $product->nid))->fetchAssoc();
$product->ups = $ups_data;
$pkg_form = array(
'#type' => 'fieldset',
'#title' => t('Package !id', array('!id' => $id)),
);
$pkg_form['products'] = array(
'#theme' => 'item_list',
'#items' => $product_list,
);
$pkg_form['package_id'] = array(
'#type' => 'hidden',
'#value' => $id,
);
$pkg_form['pkg_type'] = array(
'#type' => 'select',
'#title' => t('Package type'),
'#options' => $pkg_types,
'#default_value' => $product->ups['pkg_type'],
'#required' => TRUE,
);
$pkg_form['declared_value'] = array(
'#type' => 'textfield',
'#title' => t('Declared value'),
'#default_value' => $declared_value,
'#required' => TRUE,
);
$pkg_form['weight'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('uc-inline-form', 'clearfix')),
'#description' => t('Weight of the package. Default value is sum of product weights in the package.'),
'#weight' => 15,
);
$pkg_form['weight']['weight'] = array(
'#type' => 'textfield',
'#title' => t('Weight'),
'#default_value' => isset($package->weight) ? $package->weight : 0,
'#size' => 10,
'#maxlength' => 15,
);
$pkg_form['weight']['units'] = array(
'#type' => 'select',
'#title' => t('Units'),
'#options' => array(
'lb' => t('Pounds'),
'kg' => t('Kilograms'),
'oz' => t('Ounces'),
'g' => t('Grams'),
),
'#default_value' => isset($package->weight_units) ?
$package->weight_units :
variable_get('uc_weight_unit', 'lb'),
);
$pkg_form['dimensions'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('uc-inline-form', 'clearfix')),
'#description' => t('Physical dimensions of the package.'),
'#weight' => 20,
);
$pkg_form['dimensions']['length'] = array(
'#type' => 'textfield',
'#title' => t('Length'),
'#default_value' => isset($package->length) ? $package->length : 1,
'#size' => 10,
);
$pkg_form['dimensions']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => isset($package->width) ? $package->width : 1,
'#size' => 10,
);
$pkg_form['dimensions']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => isset($package->height) ? $package->height : 1,
'#size' => 10,
);
$pkg_form['dimensions']['units'] = array(
'#type' => 'select',
'#title' => t('Units'),
'#options' => array(
'in' => t('Inches'),
'ft' => t('Feet'),
'cm' => t('Centimeters'),
'mm' => t('Millimeters'),
),
'#default_value' => isset($package->length_units) ?
$package->length_units :
variable_get('uc_length_unit', 'in'),
);
$form['packages'][$id] = $pkg_form;
}
}
$form = uc_shipping_address_form($form, $form_state, $addresses, $order);
foreach (array('delivery_email', 'delivery_last_name', 'delivery_street1', 'delivery_city', 'delivery_country', 'delivery_postal_code') as $field) {
$form['destination'][$field]['#required'] = TRUE;
}
// Determine shipping option chosen by the customer.
$method = $order->quote['method'];
$methods = module_invoke_all('uc_shipping_method');
if (isset($methods[$method])) {
$services = $methods[$method]['quote']['accessorials'];
$method = $services[$order->quote['accessorials']];
}
// Container for shipment data.
$form['shipment'] = array(
'#type' => 'fieldset',
'#title' => t('Shipment data'),
'#collapsible' => TRUE,
);
// Inform user of customer's shipping choice.
$form['shipment']['shipping_choice'] = array(
'#type' => 'markup',
'#prefix' => '
',
'#markup' => t('Customer selected "@method" as the shipping method and paid @rate', array('@method' => $method, '@rate' => uc_currency_format($order->quote['rate']))),
'#suffix' => '
',
);
// Pass shipping charge paid information on to validation function so it
// can be displayed alongside actual costs.
$form['shipment']['paid'] = array(
'#type' => 'value',
'#value' => uc_currency_format($order->quote['rate']),
);
$services = _uc_ups_service_list();
$default_service = '';
if ($method == 'ups') {
$default_service = $order->quote['accessorials'];
}
$form['shipment']['service'] = array(
'#type' => 'select',
'#title' => t('UPS service'),
'#options' => $services,
'#default_value' => $default_service,
);
$today = getdate();
$form['shipment']['ship_date'] = array(
'#type' => 'date',
'#title' => t('Ship date'),
'#default_value' => array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday']
),
);
$form['shipment']['expected_delivery'] = array(
'#type' => 'date',
'#title' => t('Expected delivery'),
'#default_value' => array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday']
),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Review shipment')
);
return $form;
}
/**
* Passes final information into shipment object.
*
* @see uc_ups_fulfill_order()
* @see uc_ups_confirm_shipment()
*/
function uc_ups_fulfill_order_validate($form, &$form_state) {
$errors = form_get_errors();
if (isset($errors)) {
// Some required elements are missing - don't bother with making
// a UPS API call until that gets fixed.
return;
}
$origin = new stdClass();
$destination = new stdClass();
$packages = array();
foreach ($form_state['values'] as $key => $value) {
if (substr($key, 0, 7) == 'pickup_') {
$field = substr($key, 7);
$origin->$field = $value;
}
elseif (substr($key, 0, 9) == 'delivery_') {
$field = substr($key, 9);
$destination->$field = $value;
}
}
// This is a total hack to work around changes made in the return value
// from uc_shipping_address_form(). That function needs to be fixed, but
// until then this should do the trick.
$origin = $form_state['values']['pickup_address'];
$origin->phone = $form_state['values']['phone'];
$origin->first_name = $form_state['values']['first_name'];
$origin->last_name = $form_state['values']['last_name'];
$origin->company = $form_state['values']['company'];
$origin->street1 = $form_state['values']['street1'];
$origin->street2 = $form_state['values']['street2'];
$origin->city = $form_state['values']['city'];
$origin->zone = $form_state['values']['zone'];
$origin->country = $form_state['values']['country'];
$origin->postal_code = $form_state['values']['postal_code'];
$origin->email = $form_state['values']['pickup_email'];
$_SESSION['ups'] = array();
$_SESSION['ups']['origin'] = $origin;
if (empty($destination->company)) {
$destination->company = $destination->first_name . ' ' . $destination->last_name;
}
// Determine if address is Residential or Commercial
$destination->residential = variable_get('uc_ups_residential_quotes', FALSE);
$_SESSION['ups']['destination'] = $destination;
foreach ($form_state['values']['packages'] as $id => $pkg_form) {
$package = uc_shipping_package_load($id);
$package->pkg_type = $pkg_form['pkg_type'];
$package->value = $pkg_form['declared_value'];
$package->weight = $pkg_form['weight']['weight'];
$package->weight_units = $pkg_form['weight']['units'];
$package->length = $pkg_form['dimensions']['length'];
$package->width = $pkg_form['dimensions']['width'];
$package->height = $pkg_form['dimensions']['height'];
$package->length_units = $pkg_form['dimensions']['units'];
$package->qty = 1;
$_SESSION['ups']['packages'][$id] = $package;
}
$_SESSION['ups']['service'] = $form_state['values']['service'];
$_SESSION['ups']['paid'] = $form_state['values']['paid'];
$_SESSION['ups']['ship_date'] = $form_state['values']['ship_date'];
$_SESSION['ups']['expected_delivery'] = $form_state['values']['expected_delivery'];
$_SESSION['ups']['order_id'] = $form_state['values']['order_id'];
$request = uc_ups_shipment_request($_SESSION['ups']['packages'], $origin, $destination, $form_state['values']['service']);
$response_obj = drupal_http_request(variable_get('uc_ups_connection_address', 'https://wwwcie.ups.com/ups.app/xml/') . 'ShipConfirm', array(
'method' => 'POST',
'data' => $request,
));
$response = new SimpleXMLElement($response_obj->data);
if (isset($response->Response->Error)) {
$error = $response->Response->Error;
$error_msg = (string) $error->ErrorSeverity . ' Error ' . (string) $error->ErrorCode . ': ' . (string) $error->ErrorDescription;
if (strpos((string) $error->ErrorSeverity, 'Hard') !== FALSE) {
form_set_error('', $error_msg);
return FALSE;
}
else {
drupal_set_message($error_msg, 'error');
}
}
$charge = new stdClass();
// if NegotiatedRates exist, quote based on those, otherwise, use TotalCharges
if (isset($response->ShipmentCharges)) {
$charge = $response->ShipmentCharges->TotalCharges;
$_SESSION['ups']['rate']['type'] = t('Total Charges');
if (isset($response->NegotiatedRates)) {
$charge = $response->NegotiatedRates->NetSummaryCharges->GrandTotal;
$_SESSION['ups']['rate']['type'] = t('Negotiated Rates');
}
}
$_SESSION['ups']['rate']['currency'] = (string) $charge->CurrencyCode;
$_SESSION['ups']['rate']['amount'] = (string) $charge->MonetaryValue;
$_SESSION['ups']['digest'] = (string) $response->ShipmentDigest;
}
/**
* Passes final information into shipment object.
*
* @see uc_ups_fulfill_order()
* @see uc_ups_confirm_shipment()
*/
function uc_ups_fulfill_order_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/store/orders/' . $form_state['values']['order_id'] . '/shipments/ups';
}
/**
* Constructs an XML shipment request.
*
* @param $packages
* Array of packages received from the cart.
* @param $origin
* Delivery origin address information.
* @param $destination
* Delivery destination address information.
* @param $ups_service
* UPS service code (refers to UPS Ground, Next-Day Air, etc.).
*
* @return
* ShipConfirm XML document to send to UPS.
*/
function uc_ups_shipment_request($packages, $origin, $destination, $ups_service) {
$store['name'] = uc_store_name();
$store['owner'] = variable_get('uc_store_owner', NULL);
$store['email'] = uc_store_email();
$store['email_from'] = uc_store_email();
$store['phone'] = variable_get('uc_store_phone', NULL);
$store['fax'] = variable_get('uc_store_fax', NULL);
$store['street1'] = variable_get('uc_store_street1', NULL);
$store['street2'] = variable_get('uc_store_street2', NULL);
$store['city'] = variable_get('uc_store_city', NULL);
$store['zone'] = variable_get('uc_store_zone', NULL);
$store['postal_code'] = variable_get('uc_store_postal_code', NULL);
$store['country'] = variable_get('uc_store_country', 840);
$account = variable_get('uc_ups_shipper_number', '');
$ua = explode(' ', $_SERVER['HTTP_USER_AGENT']);
$user_agent = $ua[0];
$services = _uc_ups_service_list();
$service = array('code' => $ups_service, 'description' => $services[$ups_service]);
$pkg_types = _uc_ups_pkg_types();
$shipper_zone = uc_get_zone_code($store['zone']);
$shipper_country = uc_get_country_data(array('country_id' => $store['country']));
$shipper_country = $shipper_country[0]['country_iso_code_2'];
$shipper_zip = $store['postal_code'];
$shipto_zone = uc_get_zone_code($destination->zone);
$shipto_country = uc_get_country_data(array('country_id' => $destination->country));
$shipto_country = $shipto_country[0]['country_iso_code_2'];
$shipto_zip = $destination->postal_code;
$shipfrom_zone = uc_get_zone_code($origin->zone);
$shipfrom_country = uc_get_country_data(array('country_id' => $origin->country));
$shipfrom_country = $shipfrom_country[0]['country_iso_code_2'];
$shipfrom_zip = $origin->postal_code;
$ups_units = variable_get('uc_ups_unit_system', variable_get('uc_length_unit', 'in'));
$package_schema = '';
foreach ($packages as $package) {
// Determine length conversion factor and weight conversion factor
// for this shipment
$length_factor = uc_length_conversion($package->length_units, variable_get('uc_ups_unit_system', variable_get('uc_length_unit', 'in')));
switch ($ups_units) {
case 'in':
$weight_factor = uc_weight_conversion($package->weight_units, 'lb');
$units = 'LBS';
$unit_name = 'Pounds';
break;
case 'cm':
$weight_factor = uc_weight_conversion($package->weight_units, 'kg');
$units = 'KGS';
$unit_name = 'Kilograms';
break;
}
$qty = $package->qty;
for ($i = 0; $i < $qty; $i++) {
$package_type = array('code' => $package->pkg_type, 'description' => $pkg_types[$package->pkg_type]);
$package_schema .= "";
$package_schema .= "";
$package_schema .= "" . $package_type['code'] . "
";
$package_schema .= "";
if ($package->pkg_type == '02' && $package->length && $package->width && $package->height) {
if ($package->length < $package->width) {
list($package->length, $package->width) = array($package->width, $package->length);
}
$package_schema .= "";
$package_schema .= "";
$package_schema .= "" . strtoupper(variable_get('uc_ups_unit_system', variable_get('uc_length_unit', 'in'))) . "
";
$package_schema .= "";
$package_schema .= "" . (floor($package->length * $length_factor) + 1) . "";
$package_schema .= "" . (floor($package->width * $length_factor) + 1) . "";
$package_schema .= "" . (floor($package->height * $length_factor) + 1) . "";
$package_schema .= "";
}
$size = $package->length * $length_factor + 2 * $length_factor * ($package->width + $package->height);
$weight = max(1, $package->weight * $weight_factor);
$package_schema .= "";
$package_schema .= "";
$package_schema .= "" . $units . "
";
$package_schema .= "" . $unit_name . "";
$package_schema .= "";
$package_schema .= "" . number_format($weight, 1, '.', '') . "";
$package_schema .= "";
if ($size > 130 && $size <= 165) {
$package_schema .= "";
}
$package_schema .= "";
$package_schema .= "";
$package_schema .= "" . variable_get('uc_currency_code', 'USD') . "";
$package_schema .= "" . number_format($package->value, 2, '.', '') . "";
$package_schema .= "";
$package_schema .= "";
$package_schema .= "";
}
}
$schema = uc_ups_access_request() . "
Complex Rate Request
1.0001
ShipConfirm
validate
";
$schema .= "";
$schema .= "" . $store['name'] . "";
$schema .= "" . variable_get('uc_ups_shipper_number', '') . "";
if ($store['phone']) {
$schema .= "" . $store['phone'] . "";
}
if ($store['fax']) {
$schema .= "" . $store['fax'] . "";
}
if ($store['email']) {
$schema .= "" . $store['email'] . "";
}
$schema .= "";
$schema .= "" . $store['street1'] . "";
if ($store['street2']) {
$schema .= "" . $store['street2'] . "";
}
$schema .= "" . $store['city'] . "";
$schema .= "$shipper_zone";
$schema .= "$shipper_zip";
$schema .= "$shipper_country";
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "" . $destination->company . "";
$schema .= "" . $destination->first_name . ' ' . $destination->last_name . "";
$schema .= "" . $destination->phone . "";
$schema .= "" . $destination->email . "";
$schema .= "";
$schema .= "" . $destination->street1 . "";
if ($destination->street2) {
$schema .= "" . $destination->street2 . "";
}
$schema .= "" . $destination->city . "";
$schema .= "$shipto_zone";
$schema .= "$shipto_zip";
$schema .= "$shipto_country";
if ($destination->residential) {
$schema .= "";
}
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "" . $origin->company . "";
$schema .= "" . $origin->first_name . ' ' . $origin->last_name . "";
$schema .= "" . $origin->phone . "";
$schema .= "" . $origin->email . "";
$schema .= "";
$schema .= "" . $origin->street1 . "";
if ($origin->street2) {
$schema .= "" . $origin->street2 . "";
}
$schema .= "" . $origin->city . "";
$schema .= "$shipfrom_zone";
$schema .= "$shipfrom_zip";
$schema .= "$shipfrom_country";
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "$account";
$schema .= "";
$schema .= "";
$schema .= "";
if (variable_get('uc_ups_negotiated_rates', FALSE)) {
$schema .= "
";
}
$schema .= "";
$schema .= "{$service['code']}
";
$schema .= "{$service['description']}";
$schema .= "";
$schema .= $package_schema;
$schema .= "";
$schema .= "";
$schema .= "";
$schema .= "GIF
";
$schema .= "";
$schema .= "";
$schema .= "GIF
";
$schema .= "";
$schema .= "";
$schema .= "";
return $schema;
}
/**
* Last chance for user to review shipment.
*
* @see uc_ups_confirm_shipment_submit()
* @see theme_uc_ups_confirm_shipment()
* @ingroup forms
*/
function uc_ups_confirm_shipment($form, &$form_state, $order) {
$form['digest'] = array(
'#type' => 'hidden',
'#value' => $_SESSION['ups']['digest']
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Request Pickup')
);
return $form;
}
/**
* Displays final shipment information for review.
*
* @see uc_ups_confirm_shipment()
* @ingroup themeable
*/
function theme_uc_ups_confirm_shipment($variables) {
$form = $variables['form'];
$output = '' . t('Ship from:') . '
';
$output .= uc_address_format(
check_plain($_SESSION['ups']['origin']->first_name),
check_plain($_SESSION['ups']['origin']->last_name),
check_plain($_SESSION['ups']['origin']->company),
check_plain($_SESSION['ups']['origin']->street1),
check_plain($_SESSION['ups']['origin']->street2),
check_plain($_SESSION['ups']['origin']->city),
check_plain($_SESSION['ups']['origin']->zone),
check_plain($_SESSION['ups']['origin']->postal_code),
check_plain($_SESSION['ups']['origin']->country)
);
$output .= '
' . check_plain($_SESSION['ups']['origin']->email);
$output .= '
';
$output .= '' . t('Ship to:') . '
';
$output .= uc_address_format(
check_plain($_SESSION['ups']['destination']->first_name),
check_plain($_SESSION['ups']['destination']->last_name),
check_plain($_SESSION['ups']['destination']->company),
check_plain($_SESSION['ups']['destination']->street1),
check_plain($_SESSION['ups']['destination']->street2),
check_plain($_SESSION['ups']['destination']->city),
check_plain($_SESSION['ups']['destination']->zone),
check_plain($_SESSION['ups']['destination']->postal_code),
check_plain($_SESSION['ups']['destination']->country)
);
$output .= '
' . check_plain($_SESSION['ups']['destination']->email);
$output .= '
';
$output .= '';
$method = uc_ups_uc_shipping_method();
$output .= '' . $method['ups']['quote']['accessorials'][$_SESSION['ups']['service']] . '
';
$output .= '' . check_plain($_SESSION['ups']['rate']['type']) . ': ' . theme('uc_price', array('price' => $_SESSION['ups']['rate']['amount'])) . ' (' . check_plain($_SESSION['ups']['rate']['currency']) . ') -- ';
$output .= '' . t('Paid') . ': ' . $_SESSION['ups']['paid'] . '
';
$ship_date = $_SESSION['ups']['ship_date'];
$output .= 'Ship date: ' . format_date(gmmktime(12, 0, 0, $ship_date['month'], $ship_date['day'], $ship_date['year']), 'uc_store');
$exp_delivery = $_SESSION['ups']['expected_delivery'];
$output .= '
Expected delivery: ' . format_date(gmmktime(12, 0, 0, $exp_delivery['month'], $exp_delivery['day'], $exp_delivery['year']), 'uc_store');
$output .= "
\n
";
$output .= drupal_render_children($form);
return $output;
}
/**
* Generates label and schedules pickup of the shipment.
*
* @see uc_ups_confirm_shipment()
*/
function uc_ups_confirm_shipment_submit($form, &$form_state) {
// Request pickup using parameters in form.
$order_id = $_SESSION['ups']['order_id'];
$packages = array_keys($_SESSION['ups']['packages']);
$request = uc_ups_request_pickup($form_state['values']['digest'], $order_id, $packages);
$result = drupal_http_request(variable_get('uc_ups_connection_address', 'https://wwwcie.ups.com/ups.app/xml/') . 'ShipAccept', array(
'method' => 'POST',
'data' => $request,
));
$response = new SimpleXMLElement($result->data);
$code = (string) $response->Response->ResponseStatusCode;
if ($code == 0) { // failed request
$error = $response->Response->Error;
$error_severity = (string) $error->ErrorSeverity;
$error_code = (string) $error->ErrorCode;
$error_description = (string) $error->ErrorDescription;
drupal_set_message(t('(@severity error @code) @description', array('@severity' => $error_severity, '@code' => $error_code, '@description' => $error_description)), 'error');
if ($error_severity == 'HardError') {
$form_state['redirect'] = 'admin/store/orders/' . $order_id . '/shipments/ups/' . implode('/', $packages);
return;
}
}
$shipment = new stdClass();
$shipment->order_id = $order_id;
$shipment->origin = clone $_SESSION['ups']['origin'];
$shipment->destination = clone $_SESSION['ups']['destination'];
$shipment->packages = $_SESSION['ups']['packages'];
$shipment->shipping_method = 'ups';
$shipment->accessorials = $_SESSION['ups']['service'];
$shipment->carrier = t('UPS');
// if NegotiatedRates exist, quote based on those, otherwise, use TotalCharges
if (isset($response->ShipmentResults->ShipmentCharges)) {
$charge = $response->ShipmentResults->ShipmentCharges->TotalCharges;
if (isset($response->ShipmentResults->NegotiatedRates)) {
$charge = $response->ShipmentResults->NegotiatedRates->NetSummaryCharges->GrandTotal;
}
}
$cost = (string) $charge->MonetaryValue;
$shipment->cost = $cost;
$shipment->tracking_number = (string) $response->ShipmentResults->ShipmentIdentificationNumber;
$ship_date = $_SESSION['ups']['ship_date'];
$shipment->ship_date = gmmktime(12, 0, 0, $ship_date['month'], $ship_date['day'], $ship_date['year']);
$exp_delivery = $_SESSION['ups']['expected_delivery'];
$shipment->expected_delivery = gmmktime(12, 0, 0, $exp_delivery['month'], $exp_delivery['day'], $exp_delivery['year']);
foreach ($response->ShipmentResults->PackageResults as $package_results) {
$package =& current($shipment->packages);
$package->tracking_number = (string) $package_results->TrackingNumber;
$label_image = (string) $package_results->LabelImage->GraphicImage;
// Save the label
$directory = 'public://ups_labels';
if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
$label_path = $directory . '/label-' . $package->tracking_number . '.gif';
if ($label_file = file_save_data(base64_decode($label_image), $label_path, FILE_EXISTS_REPLACE)) {
file_usage_add($label_file, 'uc_shipping', 'package', $package->package_id);
$package->label_image = $label_file;
}
else {
drupal_set_message(t('Could not open a file to save the label image.'), 'error');
}
}
else {
drupal_set_message(t('Could not find or create the directory %directory in the file system path.', array('%directory' => $directory)), 'error');
}
unset($package);
next($shipment->packages);
}
uc_shipping_shipment_save($shipment);
unset($_SESSION['ups']);
$form_state['redirect'] = 'admin/store/orders/' . $order_id . '/shipments';
}
/**
* Constructs an XML label and pickup request.
*
* @param string $digest
* Base-64 encoded shipment request.
* @param int $order_id
* The order id of the shipment.
* @param array $packages
* An array of package ids to be shipped.
*
* @return string
* ShipmentAcceptRequest XML document to send to UPS.
*/
function uc_ups_request_pickup($digest, $order_id = 0, $packages = array()) {
$packages = (array) $packages;
$schema = uc_ups_access_request();
$schema .= "
ShipAccept";
if ($order_id || count($packages)) {
$schema .= "\n
";
if ($order_id) {
$schema .= "" . $order_id . "\n";
}
foreach ($packages as $pkg_id) {
$schema .= "" . $pkg_id . "\n";
}
$schema .= "\n\n";
}
$schema .= "
" . $digest . "
";
return $schema;
}
/**
* Displays the shipping label for printing.
*
* Each argument is a component of the file path to the image.
*
* @ingroup themeable
*/
function theme_uc_ups_label_image() {
$args = explode('/', $_GET['q'], 8);
if (count($args) != 8) {
return MENU_NOT_FOUND;
}
$image_path = file_create_url(file_stream_wrapper_uri_normalize($args[7]));
$output = <<
View/Print Label
View/Print Label
- Print the label:
Select Print from the File menu in this browser window to print the label below.
-
Fold the printed label at the dotted line.
Place the label in a UPS Shipping Pouch. If you do not have a pouch, affix the folded label using clear plastic shipping tape over the entire label.
- GETTING YOUR SHIPMENT TO UPS
Customers without a Daily Pickup- Ground, 3 Day Select, and Standard to Canada shipments must be dropped off at an authorized UPS location, or handed to a UPS driver. Pickup service is not available for these services. To find the nearest drop-off location, select the Drop-off icon from the UPS tool bar.
-
Air shipments (including Worldwide Express and Expedited) can be picked up or dropped off. To schedule a pickup, or to find a drop-off location, select the Pickup or Drop-off icon from the UPS tool bar.
Customers with a Daily Pickup-
Your driver will pickup your shipment(s) as usual.
|
EOLABEL;
print $output;
exit();
}