You are here

function template_preprocess_commerce_order_item in Commerce Core 8.2

Prepares variables for commerce order item templates.

Default template: commerce-order-item.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing rendered fields.
  • attributes: HTML attributes for the containing element.

File

modules/order/commerce_order.module, line 81
Defines the Order entity and associated features.

Code

function template_preprocess_commerce_order_item(array &$variables) {

  /** @var Drupal\commerce_order\Entity\OrderItemInterface $product_variation */
  $commerce_order_item = $variables['elements']['#commerce_order_item'];
  $variables['order_item_entity'] = $commerce_order_item;
  $variables['order_item'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['order_item'][$key] = $variables['elements'][$key];
  }
}