custom/static-plugins/SamsonCustomer/src/Subscriber/CheckoutSubscriber.php line 53

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Samson\Subscriber;
  3. /***
  4.  *
  5.  * This file is part of the "SAMSON Shop" project.
  6.  *
  7.  * For the full copyright and license information, please read the
  8.  * LICENSE.txt file that was distributed with this source code.
  9.  *
  10.  *  (c) 2020
  11.  *
  12.  ***/
  13. use Samson\Service\PersistentCartService;
  14. use Shopware\Core\Checkout\Cart\Event\CheckoutOrderPlacedEvent;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. /**
  17.  * Class CheckoutSubscriber
  18.  * @package Samson\Subscriber
  19.  * @author Artur Seitz <artur.seitz@dkd.de>
  20.  */
  21. class CheckoutSubscriber implements EventSubscriberInterface
  22. {
  23.     /** @var PersistentCartService */
  24.     protected $persistentCartService;
  25.     /**
  26.      * CartSubscriber constructor.
  27.      *
  28.      * @param PersistentCartService $persistentCartService
  29.      */
  30.     public function __construct(
  31.         PersistentCartService $persistentCartService
  32.     ) {
  33.         $this->persistentCartService $persistentCartService;
  34.     }
  35.     /** {@inheritDoc} */
  36.     public static function getSubscribedEvents(): array
  37.     {
  38.         return [
  39.             CheckoutOrderPlacedEvent::class => 'onCheckoutOrderPlacedEvent',
  40.         ];
  41.     }
  42.     /**
  43.      * CheckoutOrderPlacedEvent event listener.
  44.      *
  45.      * @param CheckoutOrderPlacedEvent $event
  46.      */
  47.     public function onCheckoutOrderPlacedEvent(CheckoutOrderPlacedEvent $event): void
  48.     {
  49.         $customer $event->getOrder()->getOrderCustomer()->getCustomer();
  50.         $context $event->getContext();
  51.         $this->persistentCartService->removePersistentCart($customer$context);
  52.     }
  53. }