From a28e50c7e2b124ada1df1a5feaaec7cbb43501ad Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 23 Jan 2014 19:49:36 +0100 Subject: [PATCH] Added a way to create orders outside of the front-office context. --- core/lib/Thelia/Action/Order.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index f7ddf487b..672d312a8 100644 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -52,6 +52,8 @@ use Thelia\Model\OrderProductAttributeCombination; use Thelia\Model\OrderStatus; use Thelia\Model\OrderStatusQuery; use Thelia\Tools\I18n; +use Thelia\Model\Country; + /** * @@ -149,6 +151,7 @@ class Order extends BaseAction implements EventSubscriberInterface } protected function createOrder(EventDispatcherInterface $dispatcher, ModelOrder $sessionOrder, Currency $currency, Lang $lang, CartModel $cart, CustomerModel $customer) + { $con = \Propel\Runtime\Propel::getConnection( OrderTableMap::DATABASE_NAME @@ -156,7 +159,7 @@ class Order extends BaseAction implements EventSubscriberInterface $con->beginTransaction(); - /* use a copy to avoid errored record in session */ + $placedOrder = $sessionOrder->copy(); $placedOrder->setDispatcher($dispatcher); @@ -338,6 +341,7 @@ class Order extends BaseAction implements EventSubscriberInterface $event->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); + /* clear session */ $session ->setProcessedOrder($placedOrder)