custom/plugins/EasyCreditRatenkauf/src/Subscriber/PreventCartPersistDuringRuleEvaluation.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * (c) NETZKOLLEKTIV GmbH <kontakt@netzkollektiv.com>
  4.  * For the full copyright and license information, please view the LICENSE
  5.  * file that was distributed with this source code.
  6.  */
  7. namespace Netzkollektiv\EasyCredit\Subscriber;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. use Shopware\Core\Checkout\Cart\Event\CartVerifyPersistEvent;
  10. class PreventCartPersistDuringRuleEvaluation implements EventSubscriberInterface {
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [
  14.             CartVerifyPersistEvent::class => 'preventPersist'
  15.         ];
  16.     }
  17.     public function preventPersist(CartVerifyPersistEvent $event): void {
  18.         $prefix 'easycredit';
  19.         if (\mb_substr($event->getCart()->getToken(), 0\mb_strlen($prefix)) === $prefix) {
  20.             $event->setShouldPersist(false);
  21.         }
  22.     }
  23. }