<?php
/*
* Plugin Name : DeliveryPlus4
*
* Copyright (C) BraTech Co., Ltd. All Rights Reserved.
* http://www.bratech.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\DeliveryPlus42\Event;
use Eccube\Event\TemplateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ShoppingEvent implements EventSubscriberInterface
{
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Shopping/index.twig' => 'onTemplateShoppingIndex',
];
}
public function onTemplateShoppingIndex(TemplateEvent $event)
{
$parameters = $event->getParameters();
$form = $parameters['form'];
$cannot_order = false;
foreach($form['Shippings'] as $Shipping){
if(count($Shipping['Delivery']->vars['choices']) == 0)$cannot_order = true;
}
if($cannot_order){
$twig = '@DeliveryPlus42/default/Shopping/cannot_order.twig';
$event->addSnippet($twig);
}
}
}