How to Show WooCommerce Bookings in Cart as Available

Woo Logo

I was asked today by a fellow developer, or rather said developer asked on Slack:

“Anyone have experience with WooCommerce Bookings throwing this message “There are a maximum of 0 places remaining” – I want 2 bookings to be allowed in the cart at the same time – not throw the error.  If someone adds a property booking for say Jan 1 – Jan 11 – and someone else tries to add Jan 5 – 10 – the second person gets There are a maximum of 0 places remaining on January 5, 2018. I wouldn’t want it to be unavailable until it’s paid and checked out.”

I put together a little Gist that did exactly what was needed:

It would have been much better if WooCommerce had given a filter so that “in-cart” bookings could be discluded from the existing_bookings queries, but as there was no filter what the code above does is catch it at the other end and take them back out. There is another status “was-in-cart” that you may want to check for as well.

Like the code you see here? You can hire me at - a WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard. See all developers you can hire through Codeable here.

Posted in Code Snippets, Guides, Help Topics, Woocommerce, Wordpress and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.