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 Codeable.io - 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.