You are here

function uc_product_uc_cart_display in Ubercart 8.4

Same name and namespace in other branches
  1. 7.3 uc_product/uc_product.module \uc_product_uc_cart_display()

Implements hook_uc_cart_display().

1 call to uc_product_uc_cart_display()
uc_product_kit_uc_cart_display in uc_product_kit/uc_product_kit.module
Implements hook_uc_cart_display().

File

uc_product/uc_product.module, line 609
The product module for Ubercart.

Code

function uc_product_uc_cart_display($item) {
  $node = $item->nid->entity;
  $element = [];
  $element['nid'] = [
    '#type' => 'value',
    '#value' => $node
      ->id(),
  ];
  $element['module'] = [
    '#type' => 'value',
    '#value' => 'uc_product',
  ];
  $element['remove'] = [
    '#type' => 'submit',
    '#value' => t('Remove'),
  ];
  if ($node
    ->access('view')) {
    $element['title'] = [
      '#type' => 'link',
      '#title' => $item->title,
      '#url' => $node
        ->toUrl(),
    ];
  }
  else {
    $element['title'] = [
      '#markup' => $item->title,
    ];
  }
  $element['#total'] = $item->price->value * $item->qty->value;
  $element['#suffixes'] = [];
  $element['data'] = [
    '#type' => 'hidden',
    '#value' => serialize($item->data
      ->first()
      ->toArray()),
  ];
  $element['qty'] = [
    '#type' => 'uc_quantity',
    '#title' => t('Quantity'),
    '#title_display' => 'invisible',
    '#default_value' => $item->qty->value,
    '#allow_zero' => TRUE,
  ];
  $element['description'] = [
    '#markup' => '',
  ];
  if ($description = uc_product_get_description($item)) {
    $element['description']['#markup'] = $description;
  }
  return $element;
}