function uc_shipping_package_cancel_confirm_submit in Ubercart 6.2
Same name and namespace in other branches
- 5 shipping/uc_shipping/uc_shipping.module \uc_shipping_package_cancel_confirm_submit()
- 7.3 shipping/uc_shipping/uc_shipping.admin.inc \uc_shipping_package_cancel_confirm_submit()
Form submission handler for uc_shipping_package_cancel_confirm().
See also
uc_shipping_package_cancel_confirm()
File
- shipping/
uc_shipping/ uc_shipping.admin.inc, line 373 - Shipping administration menu items.
Code
function uc_shipping_package_cancel_confirm_submit($form, &$form_state) {
$package = uc_shipping_package_load($form_state['values']['package_id']);
$shipment = uc_shipping_shipment_load($package->sid);
$methods = module_invoke_all('shipping_method');
if (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, array(
$package->tracking_number,
));
if ($result) {
db_query("UPDATE {uc_packages} SET sid = NULL, label_image = NULL, tracking_number = NULL WHERE package_id = %d", $package->package_id);
unset($shipment->packages[$package->package_id]);
if (!count($shipment->packages)) {
uc_shipping_shipment_delete($shipment->sid);
}
}
}
$form_state['redirect'] = 'admin/store/orders/' . $form_state['values']['order_id'] . '/packages';
}