You are here

function uc_shipping_order_pane_packages in Ubercart 7.3

Same name and namespace in other branches
  1. 5 shipping/uc_shipping/uc_shipping.module \uc_shipping_order_pane_packages()
  2. 6.2 shipping/uc_shipping/uc_shipping.module \uc_shipping_order_pane_packages()

Shipping order pane callback.

See also

uc_shipping_uc_order_pane()

1 string reference to 'uc_shipping_order_pane_packages'
uc_shipping_uc_order_pane in shipping/uc_shipping/uc_shipping.module
Implements hook_uc_order_pane().

File

shipping/uc_shipping/uc_shipping.module, line 646
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_order_pane_packages($op, $order) {
  switch ($op) {
    case 'view':
    case 'customer':
      $tracking = array();
      $result = db_query("SELECT sid FROM {uc_shipments} WHERE order_id = :id", array(
        ':id' => $order->order_id,
      ));
      foreach ($result as $shipment) {
        $shipment = uc_shipping_shipment_load($shipment->sid);
        if ($shipment->tracking_number) {
          $tracking[$shipment->carrier]['data'] = $shipment->carrier;
          $tracking[$shipment->carrier]['children'][] = check_plain($shipment->tracking_number);
        }
        else {
          foreach ($shipment->packages as $package) {
            if ($package->tracking_number) {
              $tracking[$shipment->carrier]['data'] = $shipment->carrier;
              $tracking[$shipment->carrier]['children'][] = check_plain($package->tracking_number);
            }
          }
        }
      }

      // Do not show an empty pane to customers.
      if ($op == 'view' || !empty($tracking)) {
        $build['tracking'] = array(
          '#theme' => 'item_list',
          '#items' => $tracking,
        );
        return $build;
      }
      break;
  }
}