function uc_ups_void_shipment in Ubercart 8.4
Same name and namespace in other branches
- 5 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
- 6.2 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
- 7.3 shipping/uc_ups/uc_ups.module \uc_ups_void_shipment()
Instructs UPS to cancel (in whole or in part) a shipment.
Parameters
string $shipment_number: The UPS shipment tracking number.
array $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
bool 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 839 - UPS shipping quote module.
Code
function uc_ups_void_shipment($shipment_number, array $tracking_numbers = []) {
$success = FALSE;
$request = uc_ups_void_shipment_request($shipment_number, $tracking_numbers);
$ups_config = \Drupal::config('uc_ups.settings');
$resp = \Drupal::httpClient()
->post($ups_config
->get('connection_address') . 'Void', NULL, $request)
->send();
$response = new \SimpleXMLElement($resp
->getBody(TRUE));
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::messenger()
->addError((string) $error->ErrorSeverity . ' ' . (string) $error->ErrorCode . ': ' . (string) $error->ErrorDescription);
}
}
}
if (isset($response->Status)) {
if (isset($response->Status->StatusType)) {
$success = (string) $response->Status->StatusType->Code;
}
}
return (bool) $success;
}