From 9757f2e2f8ff074941ab2430992443279decb804 Mon Sep 17 00:00:00 2001 From: iesus Date: Tue, 28 Nov 2017 08:44:01 +0000 Subject: [PATCH] when re-activating order, discard old svea order --- .../Svea/Checkout/controllers/IndexController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/code/community/Svea/Checkout/controllers/IndexController.php b/app/code/community/Svea/Checkout/controllers/IndexController.php index d23b23f..e7e8c03 100644 --- a/app/code/community/Svea/Checkout/controllers/IndexController.php +++ b/app/code/community/Svea/Checkout/controllers/IndexController.php @@ -56,6 +56,8 @@ protected function _restoreQuote($id) ) { return $oldQuote; + } else { + $sveaOrderId = null; } $quote = Mage::getModel('sales/quote')->setStore(Mage::app()->getStore()); @@ -70,8 +72,16 @@ protected function _restoreQuote($id) ->unsLastRealOrderId(); $sveaOrder = $svea->createSveaOrderFromQuote($quote); + //Create a new order in Sveas end, to reset URIs. + if (!$sveaOrderId) { + $response = $sveaOrder->createOrder(); + $sveaOrderId = $response['OrderId']; + $quote->setPaymentReference($sveaOrderId)->save(); + } + //Fetch Order $response = $sveaOrder->setCheckoutOrderId((int)$sveaOrderId)->getOrder(); + //Run update. $hasErrors = $svea->sveaOrderHasErrors($sveaOrder, $quote, $response); if(!$hasErrors) {