You are here

function uc_shipping_package_cancel_confirm_submit in Ubercart 5

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

File

shipping/uc_shipping/uc_shipping.module, line 536
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_package_cancel_confirm_submit($form_id, $form_values) {
  $package = uc_shipping_package_load($form_values['package_id']);
  $shipment = uc_shipping_shipment_load($package->sid);
  $methods = module_invoke_all('shipping_method');
  if (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);
      }
    }
  }
  return 'admin/store/orders/' . $form_values['order_id'] . '/packages';
}