You are here

function commerce_add_to_cart_link_commerce_product_variation_view in Commerce Add To Cart Link 8

Same name and namespace in other branches
  1. 2.x commerce_add_to_cart_link.module \commerce_add_to_cart_link_commerce_product_variation_view()

Implements hook_ENTITY_TYPE_view() for commerce_product_variation.

File

./commerce_add_to_cart_link.module, line 94
Hook implementations of commerce_add_to_cart_link module.

Code

function commerce_add_to_cart_link_commerce_product_variation_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

  /** @var \Drupal\commerce_product\Entity\ProductVariationInterface $entity */
  if ($display
    ->getComponent('add_to_cart_link')) {
    $build['add_to_cart_link'] = (new AddToCartLink($entity))
      ->build();
  }
}