• Resolved uniqcode

    (@uniqcode)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @uniqcode,

    Thank you for contacting us. I don’t believe this is related to my plugin because there is code written to empty the cart after the payment is processed. I personally have never had an issue in my testing with the cart emptying. Here is a link to the exact line of code where the shopping cart is emptied before the redirect to the order received page.

    https://docs.paymentplugins.com/wc-stripe/api/source-class-WC_Payment_Gateway_Stripe.html#381

    When you are able to re-produce this error are you checking out from the checkout page, cart page or product page?

    Have you looked at your theme being the culprit? I have seen where some themes will cache the cart items and so it appears its not emptied after the order is placed.

    Kind Regards,

    Thread Starter uniqcode

    (@uniqcode)

    Thanks for the reply.
    You’re right, it’s not your plugin – it just happened to me again using the other Stripe plugin!
    I had seen that yours in some circumstances calls empty_cart(false) which leaves the persistent cart uncleared, that’s what made me suspicious.
    I don’t think it’s the theme either, but I’ll keep looking…
    Cheers.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cart not emptied after successful checkout’ is closed to new replies.