diff --git a/src/Sylius/Bundle/CoreBundle/Checkout/Step/PaymentShippingStep.php b/src/Sylius/Bundle/CoreBundle/Checkout/Step/PaymentShippingStep.php index b7a70bfb029..91f44051852 100755 --- a/src/Sylius/Bundle/CoreBundle/Checkout/Step/PaymentShippingStep.php +++ b/src/Sylius/Bundle/CoreBundle/Checkout/Step/PaymentShippingStep.php @@ -18,6 +18,7 @@ use Sylius\Component\Core\Model\ShippingMethod; use Sylius\Component\Core\Model\UserInterface; use Sylius\Component\Core\SyliusCheckoutEvents; +use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormInterface; /** @@ -86,6 +87,14 @@ public function forwardAction(ProcessContextInterface $context) $formShipping = $this->createCheckoutShippingForm($order, $formShippingPre->get('country')->getData()); $formShipping->handleRequest($request); + if ($formPayment->isSubmitted() && $formShipping->isSubmitted()) { + // custom validation for pandaticket cashOnDelivery and eTicket combination + // TODO remove when relations between payment and delivery will be available + if ($order->getLastPayment()->getMethod()->getGateway() == 'cashOnDelivery' && $order->getLastShipment()->getMethod()->getCategory()->isGenerateTickets()) { + $formPayment->get('paymentMethod')->addError(new FormError('funlife.eshop.form.payment.cash_on_delivery')); + } + } + if ($formPayment->isValid() && $formShipping->isValid() && (!$this->requireAddress($order) || $formAddressing->isValid())) { $compareAddr = new Address(); diff --git a/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/CountrySpecificShippingStepType.php b/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/CountrySpecificShippingStepType.php index 3655bafd0cf..36fe89475d9 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/CountrySpecificShippingStepType.php +++ b/src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/CountrySpecificShippingStepType.php @@ -123,16 +123,21 @@ public function buildView(FormView $view, FormInterface $form, array $options) $choiceList = $methodType->getConfig()->getOption('choice_list'); $requireAddress = array(); + $generateTickets = array(); /** @var ShippingMethod $shippingMethod */ $i = 0; foreach ($choiceList->getChoices() as $shippingMethod) { if ($shippingMethod->getRequireAddress()) { $requireAddress[] = $i; } + if ($shippingMethod->getCategory()->isGenerateTickets()) { + $generateTickets[] = $i; + } $i++; } $view->vars['shipping_methods_requiring_address'] = json_encode(array('ids' => $requireAddress)); + $view->vars['shipping_methods_generates_eticket'] = json_encode(array('ids' => $generateTickets)); } /** diff --git a/src/Sylius/Bundle/WebBundle/Resources/views/Common/_forms.html.twig b/src/Sylius/Bundle/WebBundle/Resources/views/Common/_forms.html.twig index 191dd5d9c2a..b131c5e87f9 100755 --- a/src/Sylius/Bundle/WebBundle/Resources/views/Common/_forms.html.twig +++ b/src/Sylius/Bundle/WebBundle/Resources/views/Common/_forms.html.twig @@ -112,7 +112,7 @@ {% spaceless %} {% if errors|length > 0 %} {% for error in errors %} -
{{ error.message }}
+
{{ error.message|trans(error.messageParameters, 'validators') }}
{% endfor %} {% endif %} {% endspaceless %} diff --git a/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/PaymentShipping/shipping.html.twig b/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/PaymentShipping/shipping.html.twig index 99657f6a11c..84a9103d360 100755 --- a/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/PaymentShipping/shipping.html.twig +++ b/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/PaymentShipping/shipping.html.twig @@ -2,7 +2,7 @@

{{ 'sylius.checkout.shipping.header'|trans|raw }}

{{ form_errors(form.shipments) }} -
+
{{ form_row(form.country, {'attr': {'autocomplete': 'off'}}) }}