You are here

function template_preprocess_commerce_wishlist in Commerce Wishlist 8.3

Prepares variables for wishlist templates.

Default template: commerce-wishlist.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_wishlist.module, line 123
Defines the Wishlist entity and associated features.

Code

function template_preprocess_commerce_wishlist(array &$variables) {

  /** @var Drupal\commerce_wishlist\Entity\WishlistInterface $wishlist */
  $wishlist = $variables['elements']['#commerce_wishlist'];
  $variables['wishlist_entity'] = $wishlist;
  $variables['wishlist'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['wishlist'][$key] = $variables['elements'][$key];
  }
}