• Hi,

    I’m using the plugin for forcing cart items to expire. It works well while the customer is active in the website, but if he leaves the website or closes the browser before the expiration time, the products seem to actually hang on in the cart till he reopens the website / browser. Is there anyway to force an expired cart cleanup on the server side, like a “cron job”?

    Cheers,
    Sebastian

    • This topic was modified 4 years, 8 months ago by Sebastian.
Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author James Golovich

    (@jamesgol)

    After the items expire in the users cart they are no longer counted for the virtual inventory. If the user comes back to visit they will get a message that their items have been removed otherwise the carts/sessions will be removed when WooCommerce purges them.

    Thread Starter Sebastian

    (@sflorian)

    Hi @jamesgol, thanks for the reply!

    My case is the following: I’m using Booking Addon for WooCommerce and if a user adds to cart a certain product as booking, it blocks other bookings for that period, that’s why the cart expiration is vital. Just, as I’ve mentioned, if the user closes the page/browser, his cart seems to remain active and the Booking Addon keeps the reservation system blocked. So, would there be an option to extend your plugin so it does check/purge the expired carts even if the user has left the page/browser?

    Cheers,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    I suspect that the this plugin isn’t working properly with the Booking Addon and adding cart expiration is only a band aid on the issue.

    Have you tested out to make sure it is actually working as you expect? I’ve never seen the Booking Addon plugin code so I can’t know for sure how it works and other people in the past have said it doesn’t work properly.

    Thread Starter Sebastian

    (@sflorian)

    The Booking Addon is working fine, I’ve tested it, actually maybe it’s to well constructed, as it checks also the temporary bookings (aka users carts) to determine the remaining places. The problem is, if the user closes the page, the session/cart remains somewhere in the database. Maybe you can give me a hint on how I could clear those sessions after a certain time.

    Cheers,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    Unfortunately there just isn’t an easy way to do this right now with the way the plugin is setup.

    I did create a feature request in the github tracker for it https://github.com/jamesgol/woocommerce-cart-stock-reducer/issues/81

    I still suspect that looking at the Bookings code would help discover how they are querying and why it isn’t working properly. Maybe they are doing direct DB queries instead of using the WooCommerce API?

    Thread Starter Sebastian

    (@sflorian)

    Hi @jamesgol, thanks a lot for your help!

    For now I’ve set up woocommerce_cleanup_sessions cron job to run every few minutes, so it deletes the unused sessions. For now this seem to work fine.

    Cheers,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    I’m not certain that will solve your problem since the default session expiry is something like 48 hours.

    Thread Starter Sebastian

    (@sflorian)

    Hi @jamesgol,

    I’ve changed the default session expiry to 2 minutes, so it seems to work like that. It would be cool for your plugin to have those settings by default though.

    Cheers,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    2 minutes seems really short for a session expiration. Someone might add an item to their cart, wait a few minutes, and try to checkout and it’s gone.

    If you email me a copy of the plugin I can take a look how it interacts when I have a chance and try to figure out the right way to handle the situation.

    Thread Starter Sebastian

    (@sflorian)

    Hi @jamesgol,

    Thanks for looking into this, the plugin can be downloaded here:

    https://www.ads-software.com/plugins/booking-for-woocommerce/

    Cheers,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    I’ve never seen that plugin before, I know people had issues with the paid one from WooCommerce.

    When I have some free time I’ll take a look.

    Plugin Author James Golovich

    (@jamesgol)

    I had a few minutes so I setup a test with that plugin. Created a booking + product with stock of 1. Added that to a cart in one window and closed the browser. Checked in another browser and it shows out of stock, 10 minutes later I refreshed and it is back in stock.

    So in my simple test it appears to work as expected. Is there a more complicated setup I can duplicate to try to reproduce your results?

    Thread Starter Sebastian

    (@sflorian)

    Hi James,

    Yes, but 10 minutes it’s a lot if someone reserves let’s say 10 places out of 12 and then closes the browser … it can block the entire reservation system for 10 minutes. But cleaning the sessions once 4 minutes seems to do the job well.

    Thanks,
    Sebastian

    Plugin Author James Golovich

    (@jamesgol)

    The 10 minutes is the expiration time I had configured, it could be configure to anything (4 minutes, 4 hours, 4 days, etc.)

    I’m trying to simulate your setup so I can make sure there isn’t an actual bug here. Since I’ve never used the Bookings plugin you are using before I can’t be sure I have it setup close to how you do.

    Thread Starter Sebastian

    (@sflorian)

    Hi @jamesgol,

    Sorry for the late reply. I understand what you are saying, but if the customer never opens the website again, the product won’t be added back to stock, right?

    Cheers,
    Sebastian

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Cart doesn’t “expire” on the server side if customer closes page / browser’ is closed to new replies.