AhmadHamdan Posted August 27, 2015 Share Posted August 27, 2015 Hello guys, I am using a custom payment module which can be found here: http://addons.prestashop.com/en/payments-gateways-prestashop-modules/17250-custom-payment-method.html The module's basic functionality was tweaked a bit so that once I create an order it redirects me to the payment gateway and after payment (regardless if successful or not) it redirects me to the return page which display the shipment tracking code and other information (or not if payment failed). I don't mind it creating an error before successful payment. My question is: how can I prevent Prestashop from clearing my cart before heading to the gateway? I noticed that if I go to the gateway and the payment fails I am redirected back to the page with the the cart emptied. Basically I want to comment out that part of the code that clears the cart and add it to the bit that handles successful transfers only. I just need someone to pinpoint it for me. Here's the snippet of code from the module that handles this issue: /**************************************************************************************************************************************/ $this->module->validateOrder((int)$cart->id, $id_order_state, $total, (Tools::strlen($custom_payment->name) ? $custom_payment->name : 'custom payment method'), null, $mail_vars, (int)$currency->id, false, $customer->secure_key); $order = new Order($this->module->currentOrder); CustomPayment::addOrderCommission($this->module->currentOrder, $this->context->currency->id, $commission); $total_paid = $order->total_paid + $commission; $order->total_paid = ($total_paid < 0 ? 0 : $total_paid); $total_paid_tax_excl = $order->total_paid_tax_excl + $commission; $order->total_paid_tax_excl = ($total_paid_tax_excl < 0 ? 0 : $total_paid_tax_excl); $total_paid_tax_incl = $order->total_paid_tax_incl + $commission; $order->total_paid_tax_incl = ($total_paid_tax_incl < 0 ? 0 : $total_paid_tax_incl); $order->save(); /**************************************************************************************************************************************/ Thanks in advance for anyone who can help. Link to comment Share on other sites More sharing options...
vekia Posted August 27, 2015 Share Posted August 27, 2015 to pay for somethnig it is necessary to create an order in prestashop. if order is created - cart is removed, and it isnt possible to get it back, because order with this cart was created Link to comment Share on other sites More sharing options...
AhmadHamdan Posted August 27, 2015 Author Share Posted August 27, 2015 Hello Vekia, Thank you for your quick reply. If that's the case then can you please elaborate on what's happening in this website: http://rouladfouni.com/shop ?? I just created an account and completed the checkout process and in the end I clicked on "pay by paypal". Once I was redirected I entered wrong credentials (therefore no order payment) and went back to the website and my order was still there. Is there something I'm missing here? Much appreciated. 1 Link to comment Share on other sites More sharing options...
Nayana Chandran Posted December 2, 2016 Share Posted December 2, 2016 Hii guys, If the transaction get failed means, how it will maintain ?? Cart will clear once after the payment is completed, either it is success or failed is right ?? Link to comment Share on other sites More sharing options...
bellini13 Posted December 2, 2016 Share Posted December 2, 2016 Hello Vekia, Thank you for your quick reply. If that's the case then can you please elaborate on what's happening in this website: http://rouladfouni.com/shop ?? I just created an account and completed the checkout process and in the end I clicked on "pay by paypal". Once I was redirected I entered wrong credentials (therefore no order payment) and went back to the website and my order was still there. Is there something I'm missing here? Much appreciated. Isn't the fundamental difference that on your site, an order is created BEFORE payment. I didn't visit this other website, but you failed to mention if an order was created BEFORE you went to paypal.. 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