Post by joeantropy » Wed Sep 08, 2021 9:41 pm

Hi all,

Trying to diagnose an issue on an OpenCart 2.1.0.2 where the customer's cart appears to empty between the points that $this->model_checkout_order->addOrder() and $this->model_checkout_order->addOrderHistory() are called, causing coupon errors and setting the order status to 'Cancelled' (fraud_status_id). It looks like it might be another marvellous session issue but can't say for sure.

By adding lots of logging code, I've narrowed it down to coupons that are restricted to certain products/categories. All orders affected had only valid products for the coupons they used. The call to model_total_coupon->getCoupon() from getTotal() at step 6 of the checkout goes through OK, but when calling model_total_coupon->confirm() during addOrderHistory, getCoupon() returns null. Logs show that it finds no products in the customer's cart that are valid for the coupon and sets $status to false (line 71). It compares against $this->cart->getProducts(), which returns the customer's cart as expected when calling from addOrder() and model_total_coupon->getTotal(), but when calling from addOrderHistory() and model_total_coupon->confirm() it returns an empty array.

It looks like the customer's cart is somehow being prematurely emptied between these two points, or the customer's session is being reset. I've made a previous thread about this issue and we have the fix mentioned there in place on this site (SameSite=None for the session cookie). The issue happens at random, with some orders with coupons going through fine and some being 'cancelled' due to an 'empty' cart. There doesn't seem to be any relation to payment methods either that might suggest any bugs with a particular payment controller, all orders affected use a different payment method (various barclaycard_cw methods as well as the default OpenCart paypal (pp_standard)). We've been unable to reproduce the issue on our end in tests. Wondering if anyone's encountered a similar issue and whether they've had any luck either reproducing or finding what was causing it?

User avatar
Newbie

Posts

Joined
Mon Mar 02, 2020 10:19 pm

Post by ADD Creative » Wed Sep 08, 2021 10:34 pm

There were issue with 2.x using coupons with payment modules that use a callback, such a PayPal Standard. Maybe have a good read of this issue if you haven't already. https://github.com/opencart/opencart/issues/3657

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 34 guests