A customer recently reached out with an issue with WooCommerce Bookings. Abandoned cart booking items weren’t being cleared out for others to book.
When a customer adds a booking product to their cart, it becomes unavailable for other customers to simultaneously book. But if the first customer leaves the site without booking, that booking needs to become available. WooCommerce Bookings is set up by default to release bookings after 60 minutes of inactivity, but what do you do if they aren’t getting cleared out?
Bookings In Cart
WooCommerce Bookings has a special status called In Cart that will show you how many customers have booking items in their carts:
If you find that items stay In Cart for longer than expected, you may be running into the same issue that our customer did.
How booking items are cleared
WooCommerce Bookings uses WordPress Cron to schedule the clearing of In Cart items. You can see this in action by installing WP Crontrol plugin and looking for wc-booking-remove-inactive-cart
:
Once an item is added to the cart, a cron event get created to run 60 minutes later if it’s still in the cart. If the customer doesn’t check out in 60 minutes, the item is deleted and added back to the pool.
Got Cron but items not deleting
If you can see the cron event scheduled, but it never actually clears out, you may be running into a known issue with WordPres Cron – the events never actually run…
WordPress Cron is dependent on a page load from a visitor to the site, so if your site gets light or spotty traffic, these events might never get triggered to run. Some folks call WordPress Cron faux cron jobs.
Set up actual cron events
The easiest way to solve this issue is to set up a ‘real’ cron event schedule to trigger WP Cron (rather than a page view). This is handled in slightly different ways depending on your host, but check out our article on scheduling cron events. It’s based on a standard Linux / cPanel hosting setup and will likely cover your needs.
Once your cron events have been scheduled, check back in on WP Crontrol and double check your work. In our cron article we suggested setting up a schedule to run every half hour. In this scenario an item might remain in the cart an extra half hour at max, but it certainly beats it never getting cleared at all.
5 Comments
Hi, thanks for the infos and the solution for the cron jobs not running :)
Is there any way to increase the time the products will remain in the cart by adressing the cronjob?
Hi Hagen,
No, you wouldn’t adjust that using a cron job. They are only for running specific scripts at specific times. I would check with WooCommerce Bookings for how to adjust the default 60 minutes. I’m guessing you’d use an action filter for that.
Thanks so much for this post! Was worked for me to stop some Bookings Reminders.
I didn’t know about this plugin: WP Crontrol
Thank you for mentioning it.
add_filter(‘woocommerce_bookings_remove_inactive_cart_time’, changeDeleteTime());
function changeDeleteTime(){
return time() + ( 30 * 24 * 60 * 60 );
}
can you update this for 2023
Comments are closed.