Skip navigation
Help

hook_uc_order_actions

7 uc_order.api.php hook_uc_order_actions($order)

Adds links to local tasks for orders on the admin's list of orders.

Parameters

$order: An order object.

Return value

An array of specialized link arrays. Each link has the following keys:

  • name: The title of page being linked.
  • url: The link path. Do not use url(), but do use the $order's order_id.
  • icon: HTML of an image.
  • title: Title attribute text (mouseover tool-tip).

Related topics

1 function implements hook_uc_order_actions()

1 invocation of hook_uc_order_actions()

File

ubercart/uc_order/uc_order.api.php, line 209
Hooks provided by the Order module.

Code

function hook_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')), 
        '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')), 
          'title' => $title,
        );
      }
    }
  }
  return $actions;
}