app/Plugin/EccubePaymentLite4/EventListener/EventSubscriber/Front/Shopping/RemoveGuestPurchaseBtnWhenShoppingLogin.php line 30

Open in your IDE?
  1. <?php
  2. namespace Plugin\EccubePaymentLite4\EventListener\EventSubscriber\Front\Shopping;
  3. use Eccube\Entity\CartItem;
  4. use Eccube\Event\TemplateEvent;
  5. use Eccube\Service\CartService;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class RemoveGuestPurchaseBtnWhenShoppingLogin implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var CartService
  11.      */
  12.     private $cartService;
  13.     public function __construct(
  14.         CartService $cartService
  15.     ) {
  16.         $this->cartService $cartService;
  17.     }
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             'Shopping/login.twig' => 'index',
  22.         ];
  23.     }
  24.     public function index(TemplateEvent $templateEvent)
  25.     {
  26.         $Cart $this->cartService->getCart();
  27.         /* @var CartItem $cartItem */
  28.         $cartItem $Cart->getItems()->first();
  29.         if ($cartItem->getProductClass()->getSaleType()->getName() !== '定期商品') {
  30.             return;
  31.         }
  32.         $templateEvent
  33.             ->addSnippet('@EccubePaymentLite4/default/Shopping/remove_guest_purchase_btn.twig');
  34.     }
  35. }