You are here

function uc_ups_void_shipment in Ubercart 5

Same name and namespace in other branches
  1. 8.4 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
  2. 6.2 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
  3. 7.3 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
1 string reference to 'uc_ups_void_shipment'
uc_ups_shipping_method in shipping/uc_ups/uc_ups.module
Implementation of Übercart's hook_shipping_method().

File

shipping/uc_ups/uc_ups.module, line 1447
Shipping quote module that interfaces with www.ups.com to get rates for small package shipments.

Code

function uc_ups_void_shipment($shipment_number, $tracking_numbers = array()) {
  include_once drupal_get_path('module', 'uc_store') . '/includes/simplexml.php';
  $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(), 'POST', $request);
  $response = new JSimpleXML();
  $response
    ->loadString($resp->data);
  if (is_array($response->document->response)) {
    if (is_array($response->document->response[0]->responsestatuscode)) {
      $success = $response->document->response[0]->responsestatuscode[0]
        ->data();
    }
    if (is_array($response->document->response[0]->error)) {
      foreach ($response->document->response[0]->error as $error) {
        drupal_set_message($error->errorseverity[0]
          ->data() . ' ' . $error->errorcode[0]
          ->data() . ': ' . $error->errordescription[0]
          ->data(), 'error');
      }
    }
  }
  if (is_array($response->document->status)) {
    if (is_array($response->document->status[0]->statustype)) {
      $success = $response->document->status[0]->statustype[0]->code[0]
        ->data();
    }
  }
  return (bool) $success;
}