Hey Stephen,
In the case of recurring events, there a way to block bookings the next day so that customers can’t give less than 24 hours notice?
E.g. let’s say I offer tours, and it’s currently 5pm on Thursday where I am. At the moment, someone could book a tour departing on Friday which means I may end up with more people than anticipated (though not necessarily more than my maximum allocation). Say I book a smaller bus for 20 people because I’d only sold 18 tickets, then overnight 10 more people booked for that same tour so my bus is now too small. Make sense?
So is there a way that I could be sure that nobody can book a tour until Saturday by automatically blocking out the Friday? Then on Fridays, Saturday would be automatically blocked out, and so on.
Hope this makes sense, and hope you can point me in the right direction.
Cheers!
TS
Yes, that’s possible. There is a filter that let’s you filter which dates can are available for booking. Simply remove any occurrences that are less than 24 hours away.
Documentation and example can be found here: http://codex.wp-event-organiser.com/hook-eventorganiser_bookable_occurrences.html
Stephen Harris
Hello again,
Thanks for the information and link. Unfortunately it’s not doing what I’d hoped – instead of blocking out the next day in the calendar view, it prevents users from booking at all and says ‘This event has sold out’. Or have I perhaps implemented it incorrectly?
You can see an example of one of the tours here: http://bit.ly/2yCkhkQ (others are available via this link too).
I realised in my initial post that I didn’t clearly state that although bookings should not be allowed for the following day, they are okay for days that follow. So on a Friday, I don’t want users to be able to book for the Saturday, but they can book Sunday, Monday, etc.
It’s very possible that the filter you told me about does exactly this, but I’m not sure how to implement it exactly. Logically, I need it to do this:
- if recurring event is < 1 day away, prevent users selecting it on the calendar layout
- if recurring event is > 1 day away, allow bookings via the calendar as normal
- apply same rule to all events across the site
Thanks again for your help, it’s very much appreciated.
FYI, the first filter in the codex returns an error: “Notice: Undefined variable: occurrences”.
TS
There was an error on that example. Try:
add_filter( 'eventorganiser_bookable_occurrences', function( $bookable, $event_id ) {
$in24hours= new DateTime( '+1 days', eo_get_blog_timezone() );
foreach( $bookable as $occurrence_id => $occurrence ) {
//Bookings close 1 day before event starts
if ( $in24hours > $occurrence['start'] ) {
unset( $bookable[$occurrence_id] );
}
}
return $bookable;
}, 10, 2 );
Stephen Harris
Hello once again,
Thank you so much for your help, it’s working as I hoped now.
Thanks too for your prompt replies, and for the plugin itself. Very much appreciated.
Cheers!
TS