You are here

function hook_uc_order_actions in Ubercart 8.4

Same name and namespace in other branches
  1. 7.3 uc_order/uc_order.api.php \hook_uc_order_actions()

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

Parameters

\Drupal\uc_order\OrderInterface $order: An order object.

Return value

array An array of operations links. Each link has the following keys:

  • title: The title of page being linked.
  • href: The link path. Do not use url(), but do use the $order's order_id.
  • weight: Sets the display order of operations.
1 function implements hook_uc_order_actions()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_fulfillment_uc_order_actions in shipping/uc_fulfillment/uc_fulfillment.module
Implements hook_uc_order_actions().
1 invocation of hook_uc_order_actions()
uc_order_actions in uc_order/uc_order.module
Returns the actions a user may perform on an order.

File

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

Code

function hook_uc_order_actions(OrderInterface $order) {
  $account = \Drupal::currentUser();
  $actions = [];
  if ($account
    ->hasPermission('fulfill orders')) {
    $result = db_query("SELECT COUNT(nid) FROM {uc_order_products} WHERE order_id = :id AND data LIKE :data", [
      ':id' => $order
        ->id(),
      ':data' => '%s:9:\\"shippable\\";s:1:\\"1\\";%',
    ]);
    if ($result
      ->fetchField()) {
      $actions['package'] = [
        'title' => t('Package'),
        'href' => 'admin/store/orders/' . $order
          ->id() . '/packages',
        'weight' => 12,
      ];
      $result = db_query("SELECT COUNT(package_id) FROM {uc_packages} WHERE order_id = :id", [
        ':id' => $order
          ->id(),
      ]);
      if ($result
        ->fetchField()) {
        $actions['ship'] = [
          'title' => t('Ship'),
          'href' => 'admin/store/orders/' . $order
            ->id() . '/shipments',
          'weight' => 13,
        ];
      }
    }
  }
  return $actions;
}