You are here

function uc_shipping_uc_order_actions in Ubercart 7.3

Implements hook_uc_order_actions().

File

shipping/uc_shipping/uc_shipping.module, line 310
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_uc_order_actions($order) {
  $actions = array();
  if (user_access('fulfill orders')) {
    $result = db_query("SELECT COUNT(nid) FROM {uc_order_products} WHERE order_id = :id AND data LIKE :data", array(
      ':id' => $order->order_id,
      ':data' => '%s:9:\\"shippable\\";s:1:\\"1\\";%',
    ));
    if ($result
      ->fetchField()) {
      $title = t('Package order !order_id products.', array(
        '!order_id' => $order->order_id,
      ));
      $actions[] = array(
        'name' => t('Package'),
        'url' => 'admin/store/orders/' . $order->order_id . '/packages',
        'icon' => theme('image', array(
          'path' => drupal_get_path('module', 'uc_shipping') . '/images/package.gif',
          'alt' => $title,
        )),
        'title' => $title,
      );
      $result = db_query("SELECT COUNT(package_id) FROM {uc_packages} WHERE order_id = :id", array(
        ':id' => $order->order_id,
      ));
      if ($result
        ->fetchField()) {
        $title = t('Ship order !order_id packages.', array(
          '!order_id' => $order->order_id,
        ));
        $actions[] = array(
          'name' => t('Ship'),
          'url' => 'admin/store/orders/' . $order->order_id . '/shipments',
          'icon' => theme('image', array(
            'path' => drupal_get_path('module', 'uc_shipping') . '/images/ship.gif',
            'alt' => $title,
          )),
          'title' => $title,
        );
      }
    }
  }
  return $actions;
}