From 2774ec7574ff8f5d0544552632b3f191a2c9f277 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Fri, 31 Aug 2012 12:22:47 +0000 Subject: [PATCH] // Fix guest-tracking links --- controllers/front/OrderConfirmationController.php | 14 +++++++++++--- controllers/front/OrderController.php | 3 ++- controllers/front/OrderOpcController.php | 3 ++- themes/default/order-confirmation.tpl | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index 3beba0cbe..2b735fc5a 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -47,17 +47,24 @@ class OrderConfirmationControllerCore extends FrontController /* check if the cart has been made by a Guest customer, for redirect link */ if (Cart::isGuestCartByCartId($this->id_cart)) + { + $is_guest = true; $redirectLink = 'index.php?controller=guest-tracking'; + } else $redirectLink = 'index.php?controller=history'; $this->id_module = (int)(Tools::getValue('id_module', 0)); $this->id_order = Order::getOrderByCartId((int)($this->id_cart)); $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)) Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '&slowvalidation' : '')); - - $order = new Order((int)($this->id_order)); $this->reference = $order->reference; if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) Tools::redirect($redirectLink); @@ -85,7 +92,8 @@ class OrderConfirmationControllerCore extends FrontController $this->context->smarty->assign(array( 'id_order' => $this->id_order, '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 */ $this->context->customer->mylogout(); diff --git a/controllers/front/OrderController.php b/controllers/front/OrderController.php index b22a0c48d..45f74cf6b 100644 --- a/controllers/front/OrderController.php +++ b/controllers/front/OrderController.php @@ -171,9 +171,10 @@ class OrderControllerCore extends ParentOrderController { if ($this->context->customer->is_guest) { + $order = new Order((int)$id_order); $email = $this->context->customer->email; $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 Tools::redirect('index.php?controller=history'); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 086957ba2..0dfb052ad 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -165,10 +165,11 @@ class OrderOpcControllerCore extends ParentOrderController /* Bypass payment step if total is 0 */ if (($id_order = $this->_checkFreeOrder()) && $id_order) { + $order = new Order((int)$id_order); $email = $this->context->customer->email; if ($this->context->customer->is_guest) $this->context->customer->logout(); // If guest we clear the cookie for security reason - die('freeorder:'.$id_order.':'.$email); + die('freeorder:'.$order->reference.':'.$email); } exit; break; diff --git a/themes/default/order-confirmation.tpl b/themes/default/order-confirmation.tpl index 62ed2744a..0514549dc 100644 --- a/themes/default/order-confirmation.tpl +++ b/themes/default/order-confirmation.tpl @@ -40,8 +40,8 @@
{if $is_guest}

{l s='Your order ID is:'} {$id_order_formatted} . {l s='Your order ID has been sent to you via e-mail.'}

- {l s='Follow my order'} - {l s='Follow my order'} + {l s='Follow my order'} + {l s='Follow my order'} {else} {l s='Back to orders'} {l s='Back to orders'}