You are here

public function CartSubscriber::addToCart in Facebook Pixel 8

Add to cart event.

Parameters

\Drupal\commerce_cart\Event\CartEntityAddEvent $event: The cart entity add event.

File

modules/facebook_pixel_commerce/src/EventSubscriber/CartSubscriber.php, line 71

Class

CartSubscriber
Cart subscriber.

Namespace

Drupal\facebook_pixel_commerce\EventSubscriber

Code

public function addToCart(CartEntityAddEvent $event) {
  $data = $this->facebookCommerce
    ->getOrderItemData($event
    ->getOrderItem());

  // Trigger the AddToCart event and force a session to be used.
  $this->facebookEvent
    ->addEvent('AddToCart', $data, TRUE);
}