/** * Checkout payment step * * @param CartInterface $cart Cart * * @return Response Response * * @Route( * path = "/payment", * name = "store_checkout_payment", * methods = {"GET"} * ) * @EntityAnnotation( * class = { * "factory" = "elcodi.wrapper.cart", * "method" = "get", * "static" = false * }, * name = "cart" * ) */ public function paymentAction(CartInterface $cart) { /** * If some address is missing in loaded cart, then we should go back to * address screen */ if (!$cart->getDeliveryAddress() instanceof AddressInterface || !$cart->getBillingAddress() instanceof AddressInterface) { return $this->redirect($this->generateUrl('store_checkout_address')); } /** * Available payment methods */ $paymentMethods = $this->get('elcodi.wrapper.payment_methods')->get($cart); /** * Available shipping methods */ $shippingMethods = $this->get('elcodi.wrapper.shipping_methods')->get($cart); /** * By default, if the cart has not shipping data and we have available * some of them, we assign the first one. * Then we reload page to recalculate cart values */ if ($cart->getShippingMethod() == null && !empty($shippingMethods)) { $shippingMethodApplied = reset($shippingMethods); $cart->setShippingMethod($shippingMethodApplied->getId()); $this->get('elcodi.object_manager.cart')->flush($cart); return $this->redirect($this->generateUrl('store_checkout_payment')); } $cartCoupons = $this->get('elcodi.manager.cart_coupon')->getCartCoupons($cart); return $this->renderTemplate('Pages:checkout-payment.html.twig', ['shippingMethods' => $shippingMethods, 'paymentMethods' => $paymentMethods, 'cart' => $cart, 'cartCoupons' => $cartCoupons]); }