You are here

function uc_shipping_shipment_delete_confirm_submit in Ubercart 7.3

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

Submit handler for uc_shipping_shipment_delete_confirm().

See also

uc_shipping_shipment_delete_confirm()

File

shipping/uc_shipping/uc_shipping.admin.inc, line 1139
Shipping administration menu items.

Code

function uc_shipping_shipment_delete_confirm_submit($form, &$form_state) {
  $shipment = uc_shipping_shipment_load($form_state['values']['sid']);
  $methods = module_invoke_all('uc_shipping_method');
  if ($shipment->tracking_number && isset($methods[$shipment->shipping_method]['cancel']) && 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_state['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_state['values']['sid']);
  }
  $form_state['redirect'] = 'admin/store/orders/' . $form_state['values']['order_id'] . '/shipments';
}