Close Ticket Availability Prior to Event Start Date

WordPress Event Management, Calendars & Registration Forums General Question Close Ticket Availability Prior to Event Start Date

This topic contains 5 replies, has 2 voices, and was last updated by  Stephen Harris 3 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #39551

    Hello Everyone

    Is there anyway to set a date for bookings (start date) for that tickets are only available X days prior to the start date? Ie we run a hiking tour business and want to set a cut of date/time 2 days before the tours – as taking a order (ticket) sale 2 hours before the start date doesn’t make sense.

    Martin Suchta
    #39572

    Hi Martin,

    It’s possible to specify an end date/time for a ticket (i.e. after which the ticket will no longer appear on sale). These appear as ‘sale period’ start/end datetimes when creating a ticket..

    If this is a recurring event for which you are selling tickets for individual dates that would probably be impractical to use (creating a ticket for each occurrence individually, and specify the sale period end date). For that there is a hook which would allow you to configure a ticket to be on/off sale based on some code. I can share an example if the above feature isn’t suitable.

    Stephen Harris
    #39906

    Hello Stephen

    I would be so grateful if you could share the code for the above functionality.

    I definitely need the ability to set a X date prior to each ticket event date.

    For example I have a tour which can be purchased for every day from today to the end of the year. When I setup the ticket you are right I cannot set a 2 week prior to event on each ticket ticket (ie 1 for each day – over 300 tickets) so your code solution would be brilliant.

    Martin Suchta
    #39945

    Hi Martin,

    The following closes all tickets for events within two week’s time (i.e. it works at the event/date level rather than individual tickets)

    add_filter( 'eventorganiser_bookable_occurrences', function( $bookable, $event_id ) {
        $fortnight = new DateTime( '+14 days', eo_get_blog_timezone() );
        foreach( $bookable as $occurrence_id => $occurrence ) {
            //Bookings close 2 weeks before event starts
            if ( $fortnight > $occurrence['start'] ) {
                unset( $bookable[$occurrence_id] );
            }
        }
        return $bookable;
    }, 10, 2 );
    
    Stephen Harris
    #40238

    Hey Stephen

    Thank you for the above code. So which file would I add the above code into?

    Than do I code a call out to this add_filter function? If so where?

    Thank you so much for your help and a awesome product!

    Martin Suchta
    #40245

    Hi Martin,

    This blog post details where you can put the code: https://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/ (in short, a custom plugin preferable, but you can put it in your theme’s functions.php)

    Stephen Harris
Viewing 6 posts - 1 through 6 (of 6 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.