You are here

function uc_order_user_view in Ubercart 8.4

Same name and namespace in other branches
  1. 7.3 uc_order/uc_order.module \uc_order_user_view()

Implements hook_user_view().

File

uc_order/uc_order.module, line 127
Handles all things concerning Ubercart orders.

Code

function uc_order_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display, $view_mode) {
  $user = \Drupal::currentUser();
  if ($view_mode == 'full' && $user
    ->isAuthenticated() && ($user
    ->id() == $account
    ->id() && $user
    ->hasPermission('view own orders') || $user
    ->hasPermission('view all orders'))) {
    $build['orders'] = [
      '#type' => 'item',
      '#title' => t('Orders'),
      '#markup' => Link::createFromRoute(t('Click here to view your order history.'), 'view.uc_order_history.page_1', [
        'user' => $account
          ->id(),
      ])
        ->toString(),
    ];
  }
}