Support » Plugin: WooCommerce Side Cart (Ajax) » Clear Cart when user leave the Website

  • Resolved sally

    (@sallyruchman)


    Hello,

    is there the possibility with the WooSide Cart Premium Plugin, that when a user leave the Shop Page or Website the Products in the Cart get cleared automatically, so the next user dont find a cart with already added products?

    Thx
    Best regards
    Sally

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xootix

    (@xootix)

    Hello,

    Cart is specific to user & browser.
    Items are not saved in the database.
    Something else is causing this strange behavior. You should start debugging by deactivating other plugins

    sally

    (@sallyruchman)

    Hello,

    in my case with wp rocket i had to do this:

    Exclude Based on Cookies
    Pages can be excluded from the cache based on the presence of a cookie.
    For example, if you are using WooCommerce with a PHP-driven cart widget, go to WP Rocket → Advanced Rules and enter the following value in the Never Cache Cookies field:

    woocommerce_items_in_cart

    Then i found here the Solution:
    https://stackoverflow.com/questions/20954448/how-to-clear-a-woocommerce-cart

    This snippet works great for me WordPress 5.4.2:

    /*empty cart if user come to homepage*/
    add_action( ‘init’, ‘woocommerce_clear_cart_url’ );
    function woocommerce_clear_cart_url() {
    global $woocommerce;

    if ($_SERVER[‘REQUEST_URI’] === ‘/’) {
    $woocommerce->cart->empty_cart();
    }
    }

    Thx

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.