Prevent bookings for the next day

This topic contains 4 replies, has 2 voices, and was last updated by  TS 6 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28527

    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
    #28533

    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
    #28580

    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
    #28581

    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
    #28583

    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
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.