Woo Commerce Cart not clearing after purchase

Hi there,

I’m have trouble with the WooCommerce checkout. The Shopping cart isn’t clearing after someone purchases. When they come back to the site the product is still in their shopping cart?

Hi,

To achieve that you can try adding this in your child theme’s functions.php file.

add_action( 'woocommerce_thankyou', 'order_received_empty_cart_action', 10, 1 );
function order_received_empty_cart_action( $order_id ){
    WC()->cart->empty_cart();
}

For more information kindly refer to the links below

https://docs.woocommerce.com/wc-apidocs/class-WC_Cart.html

Hope this helps

Hi @paul.r,

Thanks for the reply will let you know the result.

Steve.

You’re welcome Steve :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.