Presta Web Developer Posted November 9, 2021 Share Posted November 9, 2021 Hi, I have a problem for some customers. When someone buy a product, they should go to the order confirmation site. The correct flow: 1. 4 step ptestashop checkout 2. Redirected to external payment gateway (in this step the customer leaves my site, to make payment) 3. Order confirmation page In step 3, some customers, get an 302 on the Order confirmation site, and is redirected to history. I have debug the code and can see the redirct happening in /PRESTASHOPPATH/controller/front/OrderConfirmationController.php, init function: public function init() { parent::init(); if (true === (bool) Tools::getValue('free_order')) { $this->checkFreeOrder(); } $this->id_cart = (int) (Tools::getValue('id_cart', 0)); $redirectLink = 'index.php?controller=history'; $this->id_module = (int) (Tools::getValue('id_module', 0)); $this->id_order = Order::getIdByCartId((int) ($this->id_cart)); $this->secure_key = Tools::getValue('key', false); $order = new Order((int) ($this->id_order)); if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) { Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : '')); } $this->reference = $order->reference; 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); } $this->order_presenter = new OrderPresenter(); } I have found out the problem is in the variable: $this->context->customer->id, which is null on the customers who is redirected I can't replicate the error myself. I'm running Prestashop 1.7.7.5. Does someone have an idea why? how is the context->customer object initialized, and why should it be deleted on some customers? Link to comment Share on other sites More sharing options...
Presta Web Developer Posted November 10, 2021 Author Share Posted November 10, 2021 21 hours ago, Presta Web Developer said: $order->id_customer != $this->context->customer->id I can remove the code above, to skip the check. What purpose does it have?? Link to comment Share on other sites More sharing options...
musicmaster Posted November 14, 2021 Share Posted November 14, 2021 On 11/10/2021 at 8:24 PM, Presta Web Developer said: I can remove the code above, to skip the check. What purpose does it have?? My guess would be that it prepares the Customer id for being saved in the ps_orders table with the order record for this order. Link to comment Share on other sites More sharing options...
Presta Web Developer Posted December 2, 2021 Author Share Posted December 2, 2021 On 11/14/2021 at 2:57 PM, musicmaster said: My guess would be that it prepares the Customer id for being saved in the ps_orders table with the order record for this order. Thanks for the reply. I have just checked the id_customer field in the ps_orders table and all off them are fullfilled. so I don't think thats the reason. Link to comment Share on other sites More sharing options...
pastacas Posted January 15, 2022 Share Posted January 15, 2022 Hey, I have exactly the same problem with PS 1.7.8.2. I am doing a redirect after the successful order update from my ModuleFrontController to ...index.php?controller=order-confirmation. In my ModuleFrontCOntroller the context customer is set but after the redirect somehow it gets deleted and in OrderConfirmationController.php it is null and hence the customer is not shown a successful payment page but instead order history. Any ideas? Link to comment Share on other sites More sharing options...
Gouravdev Posted January 23, 2022 Share Posted January 23, 2022 The same I'm getting for `context->cart` is null When I add any product into the cart, i got null cart and it's happening only for version 1.7.8.0 and above. Link to comment Share on other sites More sharing options...
Janett Posted January 23, 2022 Share Posted January 23, 2022 https://github.com/PrestaShop/PrestaShop/issues/26785 Link to comment Share on other sites More sharing options...
Gouravdev Posted January 23, 2022 Share Posted January 23, 2022 9 minutes ago, Janett said: https://github.com/PrestaShop/PrestaShop/issues/26785 How this is related to the above issue? Link to comment Share on other sites More sharing options...
luishuaymana Posted January 23, 2022 Share Posted January 23, 2022 And email Exists. ?? Link to comment Share on other sites More sharing options...
Gouravdev Posted January 23, 2022 Share Posted January 23, 2022 Just now, luishuaymana said: And email Exists. ?? yes, how I can cross check it? Link to comment Share on other sites More sharing options...
luishuaymana Posted January 23, 2022 Share Posted January 23, 2022 test in controller $email = '[email protected]' //add email $customer = Context::context()->customer; if (!$customer->id) { $customer->getByEmail($email); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now