// Fix guest-tracking links

This commit is contained in:
rGaillard
2012-08-31 12:22:47 +00:00
parent f5bcab7459
commit b116f50131
4 changed files with 17 additions and 7 deletions
@@ -47,17 +47,24 @@ class OrderConfirmationControllerCore extends FrontController
/* check if the cart has been made by a Guest customer, for redirect link */ /* check if the cart has been made by a Guest customer, for redirect link */
if (Cart::isGuestCartByCartId($this->id_cart)) if (Cart::isGuestCartByCartId($this->id_cart))
{
$is_guest = true;
$redirectLink = 'index.php?controller=guest-tracking'; $redirectLink = 'index.php?controller=guest-tracking';
}
else else
$redirectLink = 'index.php?controller=history'; $redirectLink = 'index.php?controller=history';
$this->id_module = (int)(Tools::getValue('id_module', 0)); $this->id_module = (int)(Tools::getValue('id_module', 0));
$this->id_order = Order::getOrderByCartId((int)($this->id_cart)); $this->id_order = Order::getOrderByCartId((int)($this->id_cart));
$this->secure_key = Tools::getValue('key', false); $this->secure_key = Tools::getValue('key', false);
$order = new Order((int)($this->id_order));
if ($is_guest)
{
$customer = new Customer((int)$order->id_customer);
$redirectLink .= '&id_order='.$order->reference.'&email='.urlencode($customer->email);
}
if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key))
Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '&slowvalidation' : '')); Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
$order = new Order((int)($this->id_order));
$this->reference = $order->reference; $this->reference = $order->reference;
if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key)
Tools::redirect($redirectLink); Tools::redirect($redirectLink);
@@ -85,7 +92,8 @@ class OrderConfirmationControllerCore extends FrontController
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'id_order' => $this->id_order, 'id_order' => $this->id_order,
'reference_order' => $this->reference, 'reference_order' => $this->reference,
'id_order_formatted' => sprintf('#%06d', $this->id_order) 'id_order_formatted' => sprintf('#%06d', $this->id_order),
'email' => $this->context->customer->email
)); ));
/* If guest we clear the cookie for security reason */ /* If guest we clear the cookie for security reason */
$this->context->customer->mylogout(); $this->context->customer->mylogout();
+2 -1
View File
@@ -171,9 +171,10 @@ class OrderControllerCore extends ParentOrderController
{ {
if ($this->context->customer->is_guest) if ($this->context->customer->is_guest)
{ {
$order = new Order((int)$id_order);
$email = $this->context->customer->email; $email = $this->context->customer->email;
$this->context->customer->mylogout(); // If guest we clear the cookie for security reason $this->context->customer->mylogout(); // If guest we clear the cookie for security reason
Tools::redirect('index.php?controller=guest-tracking&id_order='.(int)$id_order.'&email='.urlencode($email)); Tools::redirect('index.php?controller=guest-tracking&id_order='.(int)$order->reference.'&email='.urlencode($email);
} }
else else
Tools::redirect('index.php?controller=history'); Tools::redirect('index.php?controller=history');
+2 -1
View File
@@ -165,10 +165,11 @@ class OrderOpcControllerCore extends ParentOrderController
/* Bypass payment step if total is 0 */ /* Bypass payment step if total is 0 */
if (($id_order = $this->_checkFreeOrder()) && $id_order) if (($id_order = $this->_checkFreeOrder()) && $id_order)
{ {
$order = new Order((int)$id_order);
$email = $this->context->customer->email; $email = $this->context->customer->email;
if ($this->context->customer->is_guest) if ($this->context->customer->is_guest)
$this->context->customer->logout(); // If guest we clear the cookie for security reason $this->context->customer->logout(); // If guest we clear the cookie for security reason
die('freeorder:'.$id_order.':'.$email); die('freeorder:'.$order->reference.':'.$email);
} }
exit; exit;
break; break;
+2 -2
View File
@@ -40,8 +40,8 @@
<br /> <br />
{if $is_guest} {if $is_guest}
<p>{l s='Your order ID is:'} <span class="bold">{$id_order_formatted}</span> . {l s='Your order ID has been sent to you via e-mail.'}</p> <p>{l s='Your order ID is:'} <span class="bold">{$id_order_formatted}</span> . {l s='Your order ID has been sent to you via e-mail.'}</p>
<a href="{$link->getPageLink('guest-tracking', true, NULL, "id_order={$reference_order}")}" title="{l s='Follow my order'}"><img src="{$img_dir}icon/order.gif" alt="{l s='Follow my order'}" class="icon" /></a> <a href="{$link->getPageLink('guest-tracking', true, NULL, "id_order={$reference_order}&email={$email}")}" title="{l s='Follow my order'}"><img src="{$img_dir}icon/order.gif" alt="{l s='Follow my order'}" class="icon" /></a>
<a href="{$link->getPageLink('guest-tracking', true, NULL, "id_order={$reference_order}")}" title="{l s='Follow my order'}">{l s='Follow my order'}</a> <a href="{$link->getPageLink('guest-tracking', true, NULL, "id_order={$reference_order}&email={$email}")}" title="{l s='Follow my order'}">{l s='Follow my order'}</a>
{else} {else}
<a href="{$link->getPageLink('history', true)}" title="{l s='Back to orders'}"><img src="{$img_dir}icon/order.gif" alt="{l s='Back to orders'}" class="icon" /></a> <a href="{$link->getPageLink('history', true)}" title="{l s='Back to orders'}"><img src="{$img_dir}icon/order.gif" alt="{l s='Back to orders'}" class="icon" /></a>
<a href="{$link->getPageLink('history', true)}" title="{l s='Back to orders'}">{l s='Back to orders'}</a> <a href="{$link->getPageLink('history', true)}" title="{l s='Back to orders'}">{l s='Back to orders'}</a>