title: How to clear an abandoned woocommerce cart
body: <p>I came across this code for clearing a Woocommerce cart on certain page loads. </p>
  
  <p>But, I wonder is there a way to clear the cart after it has been abandoned?</p>
  
  <blockquote>
    <p>For triggering only on front page your function needs to look like this:</p>
  </blockquote>
  
  <pre><code>add_action( 'init', 'woocommerce_clear_cart_url' );
  function woocommerce_clear_cart_url() {
  global $woocommerce;
  
  if ( is_front_page() &amp;&amp; isset( $_GET['empty-cart'] ) ) { 
      $woocommerce-&gt;cart-&gt;empty_cart(); 
  }
  </code></pre>
  
  <blockquote>
    <p>}
    function is_front_page() returns true only on front page of your wordpress site. Also, you might detect any other page with function is_page() where you can pass any page title, ID or slug</p>
  </blockquote>