diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index 560e8c444..40955333f 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -67,9 +67,16 @@ class OrderConfirmationControllerCore extends FrontController if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) { Tools::redirect($redirectLink); } - $module = Module::getInstanceById((int)($this->id_module)); - if ($order->module != $module->name) { - Tools::redirect($redirectLink); + + if ($this->id_module == -1) { + if ($order->module != 'free_order') { + Tools::redirect($redirectLink); + } + } else { + $module = Module::getInstanceById((int)($this->id_module)); + if ($order->module != $module->name) { + Tools::redirect($redirectLink); + } } } @@ -405,6 +412,7 @@ class OrderConfirmationControllerCore extends FrontController $this->context->smarty->assign( array( 'refund_allowed' => (int) $order->isReturnable(), + 'is_free_order' => $this->id_module == -1 && $order->module == 'free_order', 'any_back_order' => $any_back_order, 'shw_bo_msg' => $shw_bo_msg, 'back_ord_msg' => $bo_msg, diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index c18f55c4e..2b29ef4ce 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -246,10 +246,19 @@ class OrderOpcControllerCore extends ParentOrderController if (($id_order = $this->_checkFreeOrder()) && $id_order) { $order = new Order((int)$id_order); $email = $this->context->customer->email; + $orderConfirmationUrl = $this->context->link->getPageLink('order-confirmation').'?id_cart='.$order->id_cart.'&id_module=-1'.'&id_order='.$id_order.'&key='.$order->secure_key; if ($this->context->customer->is_guest) { $this->context->customer->logout(); } // If guest we clear the cookie for security reason - $this->ajaxDie('freeorder:'.$order->reference.':'.$email); + + $return = array( + 'success' => true, + 'reference' => $order->reference, + 'email' => $email, + 'order_confirmation_url' => $orderConfirmationUrl, + ); + + $this->ajaxDie(json_encode($return)); } exit; break; diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 5ed4d1069..2a1f0756e 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -912,18 +912,17 @@ function confirmFreeOrder() url: orderOpcUrl + '?rand=' + new Date().getTime(), async: true, cache: false, - dataType : "html", + dataType : 'JSON', data: 'ajax=true&method=makeFreeOrder&token=' + static_token , - success: function(html) + success: function(response) { - $('#confirmOrder').prop('disabled', false); - var array_split = html.split(':'); - if (array_split[0] == 'freeorder') - { - if (isGuest) - document.location.href = guestTrackingUrl+'?id_order='+encodeURIComponent(array_split[1])+'&email='+encodeURIComponent(array_split[2]); - else - document.location.href = historyUrl; + if (response.success) { + $('#confirmOrder').prop('disabled', false); + if (isGuest) { + document.location.href = guestTrackingUrl+'?id_order='+encodeURIComponent(response.reference)+'&email='+encodeURIComponent(response.email); + } else { + document.location.href = response.order_confirmation_url; + } } }, error: function(XMLHttpRequest, textStatus, errorThrown) { diff --git a/themes/hotel-reservation-theme/order-confirmation.tpl b/themes/hotel-reservation-theme/order-confirmation.tpl index 23ac2a1fa..093669112 100644 --- a/themes/hotel-reservation-theme/order-confirmation.tpl +++ b/themes/hotel-reservation-theme/order-confirmation.tpl @@ -42,6 +42,9 @@ {l s='Follow my order'}
{else} + {if isset($is_free_order) && $is_free_order} +{l s='Your order on %s is complete.' sprintf=$shop_name}
{l s='Order Status :'} {l s='Confirmed'}
{l s='Order Reference :'} {$order->reference}
{if $any_back_order} diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 2d55d1485..8f53e4101 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -462,7 +462,6 @@ {addJsDef imgDir=$img_dir} {addJsDef authenticationUrl=$link->getPageLink("authentication", true)|escape:'quotes':'UTF-8'} {addJsDef orderOpcUrl=$link->getPageLink("order-opc", true)|escape:'quotes':'UTF-8'} - {addJsDef historyUrl=$link->getPageLink("history", true)|escape:'quotes':'UTF-8'} {addJsDef guestTrackingUrl=$link->getPageLink("guest-tracking", true)|escape:'quotes':'UTF-8'} {addJsDef addressUrl=$link->getPageLink("address", true, NULL, "back={$back_order_page}")|escape:'quotes':'UTF-8'} {addJsDef orderProcess='order-opc'}