function uc_shipping_package_cancel_confirm_submit in Ubercart 7.3
Same name and namespace in other branches
- 5 shipping/uc_shipping/uc_shipping.module \uc_shipping_package_cancel_confirm_submit()
- 6.2 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 438 - 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('uc_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_update('uc_packages')
->fields(array(
'sid' => NULL,
'label_image' => NULL,
'tracking_number' => NULL,
))
->condition('package_id', $package->package_id)
->execute();
if (isset($package->label_image)) {
file_usage_delete($package->label_image, 'uc_shipping', 'package', $package->package_id);
file_delete($package->label_image);
unset($package->label_image);
}
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';
}