title: Unable to clear WooComerce cart when navigating to a new page inside Wordpress
body: <p>Im trying to empty the Woocomerce cart whenever a visitor navigates to a specific page (with id #1).</p>
  <p><strong>Environment:</strong></p>
  <p>WP 5.4.2</p>
  <p>Woocomerce 4.2.2</p>
  <p>Woodmart theme</p>
  <p>Litespeed cache (disabled) <a href="https://blog.litespeedtech.com/2017/05/31/wpw-fixing-lscachewoocommerce-conflicts/" rel="nofollow noreferrer">and applied these recommendations</a></p>
  <p>Tested with google chrome/Firefox browsers. both incognito and normal mode.</p>
  <p>none of the answers <a href="https://stackoverflow.com/questions/20954448/how-to-clear-a-woocommerce-cart">on this similar question</a> helped</p>
  <p>Im using this code in functions.php:</p>
  <pre><code>add_action( 'template_redirect', 'woocommerce_clear_cart' );
  function woocommerce_clear_cart() {
    global $woocommerce, $post;
      if( $post-&gt;ID == 1) {
        WC()-&gt;cart-&gt;empty_cart();
        WC()-&gt;session-&gt;set('cart', array());
      }
  }
  </code></pre>
  <p>Result:</p>
  <ol>
  <li>customer goes to product page and adds products to cart.(my template shows the product in the mini-cart)</li>
  <li>customer navigates to page id 1.</li>
  <li>products still appears in mini-cart/or when navigating to cart page.</li>
  <li>cart is <strong>only emptied after using CTRL+F5 to reload browser</strong> without cache. or after a few times navigating between pages.</li>
  </ol>
  <p>Insights:</p>
  <ul>
  <li><strong>Expected result happens correctly</strong> when im logged in as admin (cart emptied when navigating to page 1)</li>
  <li>when <strong>emptying customer sessions</strong> (WooCommerce/Status/Tools -&gt; Clear customer sessions ) after user adds product (between step 1 and 2 ) navigating to page id 1 <strong>gives expected result.</strong></li>
  <li>im suspecting its a browser cache issue.</li>
  <li>when printing out <code>WC()-&gt;session</code> when page#1 loads i can see the cart items from step 1.</li>
  </ul>
  <p>Is there some WC method to clear the specific customer session from the DB programatically ?</p>
  <p>i also tried this code, but none of these gave me expected result</p>
  <pre><code>add_action( 'template_redirect', 'woocommerce_clear_cart' );
  function woocommerce_clear_cart() {
      if( $post-&gt;ID == 1) {
          WC()-&gt;session-&gt;set( 'cart', null );
          WC()-&gt;session-&gt;set( 'cart_totals', null );
  
          $cart = WC()-&gt;cart; 
          foreach( $cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {
  
                  $cart-&gt;remove_cart_item( $cart_item_key ); // remove it from cart
          } 
      }
  }
  </code></pre>