You are here

function uc_shipping_make_shipment in Ubercart 6.2

Same name and namespace in other branches
  1. 5 shipping/uc_shipping/uc_shipping.module \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
Implements hook_shipping_menu().

File

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

Code

function uc_shipping_make_shipment() {
  $args = func_get_args();

  //print_r($args, TRUE));
  if (count($args) > 2) {
    $order = array_shift($args);
    $method_id = array_shift($args);
    $package_ids = $args;
    $methods = module_invoke_all('shipping_method');
    if (isset($methods[$method_id])) {
      $method = $methods[$method_id];
      if (isset($method['ship']['file'])) {
        $inc_file = drupal_get_path('module', $method['module']) . '/' . $method['ship']['file'];
        if (is_file($inc_file)) {
          require_once $inc_file;
        }
      }
      return drupal_get_form($method['ship']['callback'], $order, $package_ids);
    }
    else {
      $shipment = new stdClass();
      $shipment->order_id = $order->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, $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]->order_id . '/shipments/new');
  }
}