Suporte » Desenvolvendo com WordPress » how to clean the cart when leaving the woocommerce website

  • 2btechadm

    (@2btechadm)


    I’m using this code to clean the cart:

    / * 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 ();
    }
    }
    It cleans when I access the main page, I would like it to clean every time the client closes my site.

  • O tópico ‘how to clean the cart when leaving the woocommerce website’ está fechado para novas respostas.