You are here

function template_preprocess_commerce_product_bundle in Commerce Product Bundle 8

Prepares variables for product bundle templates.

Default template: commerce-product-bundle.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_product_bundle.module, line 73
Contains commerce_product_bundle.module.

Code

function template_preprocess_commerce_product_bundle(array &$variables) {

  /** @var Drupal\commerce_product_bundle\Entity\BundleInterface $bundle */
  $product_bundle = $variables['elements']['#commerce_product_bundle'];
  $variables['product_bundle_entity'] = $product_bundle;
  $variables['product_bundle_url'] = $product_bundle
    ->toUrl();
  $variables['product_bundle'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['product_bundle'][$key] = $variables['elements'][$key];
  }
}