app/Plugin/DeliveryPlus42/Event/ShoppingEvent.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3. * Plugin Name : DeliveryPlus4
  4. *
  5. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  6. * http://www.bratech.co.jp/
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Plugin\DeliveryPlus42\Event;
  12. use Eccube\Event\TemplateEvent;
  13. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  14. class ShoppingEvent implements EventSubscriberInterface
  15. {
  16.     /**
  17.      * @return array
  18.      */
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             'Shopping/index.twig' => 'onTemplateShoppingIndex',
  23.         ];
  24.     }
  25.     public function onTemplateShoppingIndex(TemplateEvent $event)
  26.     {
  27.         $parameters $event->getParameters();
  28.         $form $parameters['form'];
  29.         $cannot_order false;
  30.         foreach($form['Shippings'] as $Shipping){
  31.             if(count($Shipping['Delivery']->vars['choices']) == 0)$cannot_order true;
  32.         }
  33.         if($cannot_order){
  34.             $twig '@DeliveryPlus42/default/Shopping/cannot_order.twig';
  35.             $event->addSnippet($twig);
  36.         }
  37.     }
  38. }