• Resolved Milan.Nikolic

    (@milannikolic)


    Hi,

    I want to know what is the default time for products staying in cart? Is that something that is defined in Woocommerce itself? And how can I change that time?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The validity of the cart is managed by two cookies, woocommerce_cart_hash and woocommerce_items_in_cart. If you look at these cookies, they are set to expire “When the browsing session ends”. However, browsers do their own thing, so the answer to how long items remain in the cart depends on what browser the customer is using and the settings in that browser. For instance, if the browser is using a setting like “on start up, continue where I left off”, then cookies would not in fact be deleted at the end of the browsing session.

    My own experience is that I’ve come back after a few days and there is still old stuff in my cart.

    Cookies are set in class-wc-cart-session.php line 243. There is no filter that I can see, so its not possible to alter the function without altering this core file, and that would make updating tiresome.

    There are filters that a developer can use to examine the cart at the moment of order. Its possible to use those filters to consider if the items are still valid and react accordingly.

    For example a developer can use the action “woocommerce_checkout_order_review” to check the order, and if no longer valid, show a message and remove payment options.

    Thread Starter Milan.Nikolic

    (@milannikolic)

    Thanks a lot for the answer.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Time the products remains in the shop’ is closed to new replies.