Cart not clearing after logout
-
I’m using latest Woocommerce & facing the problem of cart not clearing after customer logout. Customer login, adds some products to cart, and then log out, products still show in cart. I found some github and StackOverflow threads.
Solution 1 (Does not work)
//Clear cart after logout add_action( 'wp_logout', 'test_destroy_persistent_cart' ); function test_destroy_persistent_cart(){ if(function_exists('wc_empty_cart')){ wc_empty_cart(); } }
Solution 2 (Destroys cart completely, undesirable results) function your_function() { if( function_exists('WC') ){ WC()->cart->empty_cart(); } } add_action('wp_logout', 'your_function');
I believe woocommerce does this by default out of the box. Unfortunately I am facing the issue of cart not clearing after customer logout. Any tips on how to troubleshoot ?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Cart not clearing after logout’ is closed to new replies.