You are here

function template_preprocess_commerce_shipment in Commerce Shipping 8.2

Prepares variables for shipment templates.

Default template: commerce-shipment.html.twig.

Parameters

array $variables: An associative array containing:

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

File

./commerce_shipping.module, line 336
Provides core shipping functionality.

Code

function template_preprocess_commerce_shipment(array &$variables) {

  /** @var Drupal\commerce_shipping\Entity\ShipmentInterface $shipment */
  $shipment = $variables['elements']['#commerce_shipment'];
  $variables['shipment_entity'] = $shipment;
  $variables['shipment'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['shipment'][$key] = $variables['elements'][$key];
  }
}