You are here

function uc_shipping_package_view in Ubercart 5

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

Display the details of a package.

1 call to uc_shipping_package_view()
uc_shipping_shipment_view in shipping/uc_shipping/uc_shipping.module
Display shipment details.

File

shipping/uc_shipping/uc_shipping.module, line 392
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_view($package_id) {
  $package = uc_shipping_package_load($package_id);
  $shipment = uc_shipping_shipment_load($package->sid);
  $output = '';
  $rows = array();
  $output .= '<div class="order-pane pos-left"><div class="order-pane-title">' . t('Package %id:', array(
    '%id' => $package_id,
  )) . '</div>';
  $rows[] = array(
    t('Contents:'),
    filter_xss_admin($package->description),
  );
  if ($shipment) {
    $methods = module_invoke_all('shipping_method');
    $method = $methods[$shipment->shipping_method];
    $pkg_type = $method['ship']['pkg_types'][$package->pkg_type];
  }
  $rows[] = array(
    t('Package type:'),
    strlen($pkg_type) ? $pkg_type : check_plain($package->pkg_type),
  );
  if ($package->length && $package->width && $package->height) {
    $rows[] = array(
      t('Dimensions:'),
      t('!l x !w x !h', array(
        '!l' => uc_length_format($package->length),
        '!w' => uc_length_format($package->width),
        '!h' => uc_length_format($package->height),
      )),
    );
  }
  $rows[] = array(
    t('Insured value:'),
    uc_currency_format($package->value),
  );
  if ($package->tracking_number) {
    $rows[] = array(
      t('Tracking number:'),
      check_plain($package->tracking_number),
    );
  }
  if ($shipment && $package->label_image && file_exists($package->label_image)) {
    $rows[] = array(
      t('Label:'),
      l(t('Click to view.'), 'admin/store/orders/' . $package->order_id . '/shipments/labels/' . $shipment->shipping_method . '/' . $package->label_image),
    );
  }
  else {
    $rows[] = array(
      t('Label:'),
      t('n/a'),
    );
  }
  $output .= theme('table', array(), $rows, array(
    'style' => 'width:auto;',
  ));
  $output .= '</div>';
  return $output;
}