public function PixelSubscriber::addToWishlistFlag in Simple Facebook Pixel 8
Adds AddToWishlist event. Using Flag module.
Parameters
\Symfony\Component\EventDispatcher\Event $event: The add to wishlist event.
File
- src/
EventSubscriber/ PixelSubscriber.php, line 149
Class
- PixelSubscriber
- Class PixelSubscriber.
Namespace
Drupal\simple_facebook_pixel\EventSubscriberCode
public function addToWishlistFlag(Event $event) {
if ($this->pixelBuilder
->isEnabled() && $this->configFactory
->get('add_to_wishlist_flag_enabled')) {
$enabled_flags = array_filter(array_values($this->configFactory
->get('add_to_wishlist_flag_list')));
if (in_array($event
->getFlagging()
->getFlagId(), $enabled_flags)) {
$entity = $event
->getFlagging()
->getFlaggable();
if ($entity instanceof \Drupal\commerce_product\Entity\ProductInterface) {
$this
->addItem($entity
->getDefaultVariation(), 1, 'AddToWishlist');
}
}
}
}