You are here

function uc_ups_void_shipment in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
  2. 5 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
  3. 6.2 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()

Instructs UPS to cancel (in whole or in part) a shipment.

Parameters

$shipment_number: The UPS shipment tracking number.

$tracking_numbers: Array of tracking numbers for individual packages in the shipment. Optional for shipments of only one package, as they have the same tracking number.

Return value

TRUE if the shipment or packages were successfully voided.

1 string reference to 'uc_ups_void_shipment'
uc_ups_uc_shipping_method in shipping/uc_ups/uc_ups.module
Implements hook_uc_shipping_method().

File

shipping/uc_ups/uc_ups.module, line 842
UPS shipping quote module.

Code

function uc_ups_void_shipment($shipment_number, $tracking_numbers = array()) {
  $success = FALSE;
  $request = uc_ups_void_shipment_request($shipment_number, $tracking_numbers);
  $resp = drupal_http_request(variable_get('uc_ups_connection_address', 'https://wwwcie.ups.com/ups.app/xml/') . 'Void', array(
    'method' => 'POST',
    'data' => $request,
  ));
  $response = new SimpleXMLElement($resp->data);
  if (isset($response->Response)) {
    if (isset($response->Response->ResponseStatusCode)) {
      $success = (string) $response->Response->ResponseStatusCode;
    }
    if (isset($response->Response->Error)) {
      foreach ($response->Response->Error as $error) {
        drupal_set_message((string) $error->ErrorSeverity . ' ' . (string) $error->ErrorCode . ': ' . (string) $error->ErrorDescription, 'error');
      }
    }
  }
  if (isset($response->Status)) {
    if (isset($response->Status->StatusType)) {
      $success = (string) $response->Status->StatusType->Code;
    }
  }
  return (bool) $success;
}