You are here

public function PixelSubscriber::addToCartEvent in Simple Facebook Pixel 8

Adds AddToCart event.

Parameters

\Symfony\Component\EventDispatcher\Event $event: The add to cart event.

File

src/EventSubscriber/PixelSubscriber.php, line 121

Class

PixelSubscriber
Class PixelSubscriber.

Namespace

Drupal\simple_facebook_pixel\EventSubscriber

Code

public function addToCartEvent(Event $event) {
  if ($this->pixelBuilder
    ->isEnabled() && $this->configFactory
    ->get('add_to_cart_enabled')) {
    $product_variation = $event
      ->getEntity();
    $quantity = $event
      ->getQuantity();
    $this
      ->addItem($product_variation, $quantity, 'AddToCart');
  }
}