• Resolved infinityunit

    (@infinityunit)


    Hello,

    Lets say user “A” adds a product in the cart when logged in. Then, without emptying the cart user “A” logs of.

    What happens is that the product will stay in the cart.

    Then, user “B”, who is not logged in, will add products, it will increment the number of products in the cart. Showing user “A” and user “B” products.

    If a third user (user C) logs in, he will see all of the other users’ products in his or her cart.

    This was done using the same browser in the same session…

    I have deactivated my caching plugin.
    I have cleared my browser cache and cookies
    I have tried some fix with persistent cart

    but nothing seems to work. How can I make this right?

    Any help is greatly appreciated. thanks

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • MayKato

    (@maykato)

    Hello,

    I have deactivated my caching plugin.

    Have you deactivated other plugins to see if it’s caused by another plugin?
    I’ve also found a similar topic that you may want to check out:

    https://www.ads-software.com/support/topic/woocommerce-clear-cart-on-user-logout/

    Thread Starter infinityunit

    (@infinityunit)

    Hello,

    I have a strong feeling this may be cause by a cookie…

    I tried this code :

    function log_function_cart() {
    global $woocommerce;
    $woocommerce->cart->empty_cart();
    }
    add_action(‘clear_auth_cookie’, ‘log_function_cart’);

    But it didn’t work… the post you recommended is almost two years old, maybe that’s why it didn’t work… I’ll keep digging…

    Thanks

    Mirko P.

    (@rainfallnixfig)

    Hello @infinityunit,

    If you’re using caching plugins make sure the cart page is excluded from the cache. We have documentation related to this here – https://woocommerce.com/document/configuring-caching-plugins/.

    I would also reach out to the hosting provider to make sure there is no active server-side caching.

    Thread Starter infinityunit

    (@infinityunit)

    Hello, I think I was able to narrow down the issue to the cookie cart that WC writes in order to keep the products in the cart.

    When using private navigation, there is no signs of the issue. When using another computer, the cart will be empty as I believe this is considered a new session (so no cookie was there prior to the session)

    If it was a caching issue, wouldn’t the issue be there despite private navigation and the other computer? Since it is located on the server side?

    Anyhow, I came to believe that this is normal behavior for the cookie and WC. As one would not want to have the content of his or her cart deleted after logging off and logging back in…

    I think the best solution would be to write a cookie that keeps track of a shopping cart depending on users (maybe write as many cookies as there is users using the site within the same session). So user A has it own cart and user B also and they are both independent from one another… And not to forget User anonymous also…

    I lack the technical knowledge to this, but I’ll try to write to WC support to request this feature…

    Thanks

    Hi @infinityunit

    Thanks for sharing that. As you’re looking for a specific update or change to be made to WooCommerce I’d suggest re-making this post over at our idea board. This board is where our community can share their feedback or requests for change to any of our plugins or services.

    Please let us know if you have any questions!

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘cart doesn’t update when switching users’ is closed to new replies.