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