Home Forums WoodMart support forum unable to clear cart

unable to clear cart

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #216369

    shuki
    Participant

    Hi,
    see my issue here
    https://stackoverflow.com/questions/63149087/unable-to-clear-woocomerce-cart-when-navigating-to-a-new-page-inside-wordpress

    this code doesnt clear the cart, only after second refresh (hard ctrl + F5)
    there is no cache enabled.

    add_action( 'template_redirect', 'woocommerce_clear_cart' );
    function woocommerce_clear_cart() {
      global $woocommerce, $post;
        if( $post->ID == 1) {
          WC()->cart->empty_cart();
          WC()->session->set('cart', array());
        }
    }

    im seeing the products in the minicart and on the cart page itself.
    does woodmart have a cache im not aware of ?
    any suggestions ?

    #216398

    Artem Temos
    Keymaster

    Hello,

    Could you please check how it works with some default WordPress themes like WooCommerce Storefront to understand is it our theme issue or not?

    Regards

    #216402

    shuki
    Participant

    This is the easy answer….:)
    do you know if there is some cache that needs to cleaned on woodmart or minicart ?

    #216403

    Artem Temos
    Keymaster

    This mechanism comes from WooCommerce and our theme doesn’t have any special cache for this.
    But it is usually stored in browser local storage as well. That is why we asked you to check with the default theme to compare how it works.

Viewing 4 posts - 1 through 4 (of 4 total)