From 3121fc4f5f81b5f012395c2cd6db18b663afc353 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 10 Jan 2014 14:55:52 +0100 Subject: [PATCH] clear order and consumed coupon in session after processing order. Fix #162 --- core/lib/Thelia/Action/Coupon.php | 2 ++ core/lib/Thelia/Action/Order.php | 3 ++- .../Core/HttpFoundation/Session/Session.php | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 2bffb19ee..8751dae3b 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -263,6 +263,8 @@ class Coupon extends BaseAction implements EventSubscriberInterface $orderCoupon->save(); } } + + $request->getSession()->setConsumedCoupons(array()); } /** diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 792297642..1abe36508 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -287,7 +287,8 @@ class Order extends BaseAction implements EventSubscriberInterface $sessionOrder = new \Thelia\Model\Order(); $event->setOrder($sessionOrder); $event->setPlacedOrder($placedOrder); - $this->getSession()->setOrder($placedOrder); + $this->getSession()->setProcessedOrder($placedOrder); + $this->getSession()->setOrder(new \Thelia\Model\Order()); /* empty cart */ $this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest()))); diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index b35bd4a13..5179d7e56 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -253,6 +253,26 @@ class Session extends BaseSession return $this->get("thelia.order"); } + /** + * @param Order $order + * @return $this + */ + public function setProcessedOrder(Order $order) + { + $this->set('thelia.order.processed', $order); + + return $this; + } + + /** + * Return an order already processed, usefull for payment modules + * @return Order + */ + public function getProcessedOrder() + { + return $this->get('thelia.order.processed'); + } + /** * Set consumed coupons by the Customer *