You are here

function uc_shipping_shipment_delete_confirm_submit in Ubercart 5

Same name and namespace in other branches
  1. 6.2 shipping/uc_shipping/uc_shipping.admin.inc \uc_shipping_shipment_delete_confirm_submit()
  2. 7.3 shipping/uc_shipping/uc_shipping.admin.inc \uc_shipping_shipment_delete_confirm_submit()

Submit handler for uc_shipping_shipment_delete_confirm().

File

shipping/uc_shipping/uc_shipping.module, line 1111
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_shipment_delete_confirm_submit($form_id, $form_values) {
  $shipment = uc_shipping_shipment_load($form_values['sid']);
  $methods = module_invoke_all('shipping_method');
  if ($shipment->tracking_number && function_exists($methods[$shipment->shipping_method]['cancel'])) {
    $result = call_user_func($methods[$shipment->shipping_method]['cancel'], $shipment->tracking_number);
    if ($result) {
      uc_shipping_shipment_delete($form_values['sid']);
    }
    else {
      drupal_set_message(t('The shipment %tracking could not be canceled with %carrier. To delete it anyway, remove the tracking number and try again.', array(
        '%tracking' => $shipment->tracking_number,
        '%carrier' => $shipment->carrier,
      )));
    }
  }
  else {
    uc_shipping_shipment_delete($form_values['sid']);
  }
  return 'admin/store/orders/' . $form_values['order_id'] . '/shipments';
}