You are here

function uc_shipping_make_shipment in Ubercart 5

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

Default method to send packages on a shipment.

1 string reference to 'uc_shipping_make_shipment'
uc_shipping_menu in shipping/uc_shipping/uc_shipping.module
Implementation of hook_shipping_menu().

File

shipping/uc_shipping/uc_shipping.module, line 746
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_make_shipment() {
  $args = func_get_args();

  //print_r($args, true));
  if (count($args) > 2) {
    $order_id = array_shift($args);
    $method_id = array_shift($args);
    $package_ids = $args;
    $methods = module_invoke_all('shipping_method');
    $method = $methods[$method_id];
    if (isset($method)) {
      return drupal_get_form($method['ship']['callback'], $order_id, $package_ids);
    }
    else {
      $shipment = new stdClass();
      $shipment->order_id = $order_id;
      $shipment->packages = array();
      foreach ($package_ids as $id) {
        $package = uc_shipping_package_load($id);
        $shipment->packages[$id] = $package;
      }
      return drupal_get_form('uc_shipping_shipment_edit', $order_id, $shipment);
    }
  }
  else {
    drupal_set_message(t('There is no sense in making a shipment with no packages on it, right?'));
    drupal_goto('admin/store/orders/' . $args[0]);
  }
}