Closing booking for one day but not another one.

WordPress Event Management, Calendars & Registration Forums General Question Closing booking for one day but not another one.

This topic contains 4 replies, has 2 voices, and was last updated by  André Vasanne 9 years, 11 months ago.

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

    Hi there!

    On our site we are currently selling tickets by date, so in our case an event might occur every Monday, Wednesday and Friday at 3 p.m., for the next xx months, and people buy tickets for one of those events.

    The problem we are encountering is that people can book an event just a few minutes before it begins, making it almost impossible for us to react in time, which isn’t a problem if it is an event which occurs only once, since it is possible to define until when tickets are being sold.

    So my question is whether it is possible to close the booking of an event, such as the one I described, a few hours before each occurrence begins. (e.g. Wednesday at 2 p.m. no one should be able to buy a ticket for the event that starts an hour later, however the one on Friday at the same time should still be bookable.)

    Thanks in advance!

    • This topic was modified 9 years, 11 months ago by  André Vasanne.
    André Vasanne
    #16151

    Hi André

    Since 1.8 you can do the following to exclude occurrences within the next hour from the array of bookable occurrences:

    add_filter( 'eventorganiser_bookable_occurrences', 'my_set_bookable_occurrences', 10, 2 );
    function my_set_bookable_occurrences( $bookable_occurrences, $event_id ){
          $one_hours_time = new DateTime( '+1 hour', eo_get_blog_timezone() );
          if( $bookable_occurrences ){
               foreach( $bookable_occurrences as $key => $occurrence ){
                     if( $occurrence['start'] < $one_hours_time ){
                             unset( $bookable_occurrences[$key] );
                     }
               }
          }
          return $bookable_occurrences;
    }
    
    Stephen Harris
    #16165

    Thank you for your help! However I don’t know where to add these lines of code, so your help would be much appreciated!

    André Vasanne
    #16172

    Hi André,

    See this page :).

    Stephen Harris
    #16179

    Thank you very much, works perfectly!

    André Vasanne
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.