Merge pull request #757 from abhishek-webkul/gli-862
Redirect customer to order confirmation page after free order validation instead of order history page
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
<a class="button-exclusive btn btn-default" href="{$link->getPageLink('guest-tracking', true, NULL, "id_order={$reference_order|urlencode}&email={$email|urlencode}")|escape:'html':'UTF-8'}" title="{l s='Follow my order'}"><i class="icon-chevron-left"></i>{l s='Follow my order'}</a>
|
||||
</p>
|
||||
{else}
|
||||
{if isset($is_free_order) && $is_free_order}
|
||||
<p class="alert alert-success">{l s='Your order on %s is complete.' sprintf=$shop_name}</p><br />
|
||||
{/if}
|
||||
<p><strong>{l s='Order Status :'}</strong> <span>{l s='Confirmed'}</span></p>
|
||||
<p><strong>{l s='Order Reference :'}</strong> <span class="bold">{$order->reference}</span></p>
|
||||
{if $any_back_order}
|
||||
|
||||
@@ -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'}
|
||||
|
||||
Reference in New Issue
Block a user