Cart not emptied after successful checkout
-
Hi
We’ve been using your Stripe plugin for about a year now, and it was working fine until about mid-December, when we started getting reports from customers that their cart had not been emptied after successfully checking out and paying.
This has turned into a major headache for us because some customers either forget that they’ve already placed the order, or think it didn’t go through, and end up ordering twice and needing to be refunded, which of course we lose the Stripe fees on.
I’ve been trying to find the cause of this bug for weeks. It’s intermittent, so very hard to pin down. I looked at several other plugins before figuring that Stripe is the most likely culprit. I have experimentally tried using the official Stripe plugin instead, and that doesn’t appear to cause the issue.
It appears that the bug is most likely to happen when there are lots of items in the cart (our shop regularly has orders with 30+ items). Even so, I can only reproduce it maybe one in three times that I check out on my test site with a large order.
I even added the following code to my functions.php try to force the cart to be emptied:
add_action( 'woocommerce_payment_complete', 'bitternebox_empty_cart', PHP_INT_MAX ); function bitternebox_empty_cart( $order_id ){ if (! WC()->cart->is_empty()) { error_log("Cart still has items in it after successful checkout of order $order_id - emptying it now"); WC()->cart->empty_cart(); } }
The log showed this was triggered for *every* order, and yet the bug still persisted for at least some of them – it’s as if the cart was being emptied but then restored again.
I upgraded the plugin from 3.2.0 to 3.2.8 shortly before the first reports of this issue came in. Is it possible that you changed something relevant to this between those versions? (I am on 3.2.11 now and it’s still happening.)
Would really appreciate any help you can offer on this.
Ben
- The topic ‘Cart not emptied after successful checkout’ is closed to new replies.