custom/plugins/NetiNextEasyCoupon/src/Subscriber/Decoration/NEXT15687/PromotionStorefrontCartSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NetInventors\NetiNextEasyCoupon\Subscriber\Decoration\NEXT15687;
  4. use NetInventors\NetiNextEasyCoupon\Core\Checkout\Cart\AbstractCartProcessor;
  5. use Shopware\Core\Checkout\Cart\Event\BeforeLineItemAddedEvent;
  6. use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
  7. use Shopware\Core\Checkout\Promotion\Subscriber\Storefront\StorefrontCartSubscriber;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. /**
  10.  * Will become internal in v6.5.0
  11.  * TODO - Must be removed in Shopware version >= 6.5.0.0
  12.  * @psalm-suppress DeprecatedClass - Has been marked deprecated, because it will become internal in v6.5.0
  13.  */
  14. class PromotionStorefrontCartSubscriber extends StorefrontCartSubscriber
  15. {
  16.     /**
  17.      * @var StorefrontCartSubscriber
  18.      */
  19.     private $storefrontCartSubscriber;
  20.     public function __construct(
  21.         CartService              $cartService,
  22.         RequestStack             $requestStack,
  23.         StorefrontCartSubscriber $storefrontCartSubscriber
  24.     ) {
  25.         parent::__construct($cartService$requestStack);
  26.         $this->storefrontCartSubscriber $storefrontCartSubscriber;
  27.     }
  28.     public function onLineItemAdded(BeforeLineItemAddedEvent $event): void
  29.     {
  30.         $cart                    $event->getCart();
  31.         $easyCouponsReferenceIds =
  32.             $cart->getLineItems()->filterType(AbstractCartProcessor::EASY_COUPON_LINE_ITEM_TYPE)->getReferenceIds();
  33.         if (\in_array($event->getLineItem()->getReferencedId(), $easyCouponsReferenceIdstrue)) {
  34.             return;
  35.         }
  36.         $this->storefrontCartSubscriber->onLineItemAdded($event);
  37.     }
  38. }