Sell Tickets after Event has started
WordPress Event Management, Calendars & Registration › Forums › Request A Feature › Sell Tickets after Event has started
This topic contains 9 replies, has 3 voices, and was last updated by Stephen Harris 8 years, 3 months ago.
-
AuthorPosts
-
July 15, 2016 at 6:50 pm #23461
Hello, I have a members only venue that I’m trying to use your from to sell the tickets for. When I set the date to after the event it says tickets no longer available, and by default says that it stops at the start of the event. Would just like to be able to sell tickets till the event ends as an option so I don’t have to switch the lay out.
Is this possible?
Steven BigwoodJuly 18, 2016 at 12:24 pm #23464Hi Steven,
This is possible. First you would need to edit the template
event-organiser-pro/templates/eo-booking-form.php
to replace:if ( eo_get_schedule_last( DATETIMEOBJ, $booking_form->get( 'event_id' ) ) < $now ) {
with
$schedule = eo_get_event_schedule( $booking_form->get( 'event_id' ) ); if ( $schedule['schedule_finish'] < $now ) {
That conditional alters when the booking form is replaced by a message saying that the event is no longer available for bookings. By default it happens when the last occurrence has started (rather than finished – as you want it to do).
Then, in a site utility plug-in (or, less desirably, in a theme’s
functions.php
) you need to use the following snippet to include the current occurrence in the ‘bookable’ dates:add_filter( 'eventorganiser_bookable_occurrences', function( $bookable, $event_id ) { $now = new DateTime( 'now', eo_get_blog_timezone() ); $bookable = eo_get_the_occurrences_of( $event_id ); foreach( $bookable as $occurrence_id => $occurrence ) { //Remove events whose end date is in the past if ( $now > $occurrence['end'] ) { unset( $bookable[$occurrence_id] ); } } return $bookable; }, 10, 2 );
Stephen HarrisJuly 22, 2016 at 6:38 pm #23512Thanks for you reply Stephen!
The first bit of code seemed to work, and for a second yesterday I had a test event that let me sell tickets all the way till the end then it started hiding my bookings for real events almost immediately after even when I recreated them. I did notice an update roll-out and did all my testing post that too.
With the second bit of code I get a syntax error that I thought I had corrected but it seemed to have reverted back on me, I’m not quite sure what you mean by site utility plug-in; can you point me in the direction of a preferred option? Presently I’m getting a parse error that prevents any pages with tickets from loading and have had to supplement with paypal buttons which isn’t preferred at all but I’m just going to revert my booking-form.php code back for now so I can still attempt to have the booking plug-in confirmations work.
Steven BigwoodJuly 29, 2016 at 6:01 pm #23560Still waiting for a response, 6 days later, at this point affecting my business and considering alternatives.
Steven BigwoodJuly 29, 2016 at 10:08 pm #23563My apologies for the delay in replying Steven. By utility plug-in I simply a separate plug-in which you create. It’s preferable to using the theme’s functions.php in that it doesn’t tie the functionality to the theme. Please see http://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/ for more details.
I’ve used the above snippet and it did not cause a parse error, so the problem might be the version of PHP you are using. That snippet won’t work on anything older than PHP 5.3. The following would:
add_filter( 'eventorganiser_bookable_occurrences', 'my_bookable_occurrences', 10, 2 ); function my_bookable_occurrences( $bookable, $event_id ) { $now = new DateTime( 'now', eo_get_blog_timezone() ); $bookable = eo_get_the_occurrences_of( $event_id ); foreach( $bookable as $occurrence_id => $occurrence ) { //Remove events whose end date is in the past if ( $now > $occurrence['end'] ) { unset( $bookable[$occurrence_id] ); } } return $bookable; }
Stephen HarrisJuly 29, 2016 at 10:40 pm #23567Okay Got ya! I did just upgrade the PHP as it was a little dated, may have actually been 5.2 so I’ll have to see how this goes this time! Thanks
Steven BigwoodAugust 18, 2016 at 8:03 pm #23844Hello,
Would it be possible to leave registration open after an event has ended? (I’m posting in this thread as maybe it’s a similar solution to Steven’s?) I’d like people to be able to register later on so I can keep a list of everything.
Thank you!
WillowAugust 19, 2016 at 8:38 am #23846Yes, you can just
return eo_get_the_occurrences_of( $event_id );
In the filter callback. You’d also want to remove the check in the template as mentioned above.
Stephen HarrisAugust 22, 2016 at 4:16 pm #23874Hi Stephen,
Thanks for the quick reply! I changed the code in the
event-organiser-pro/templates/eo-booking-form.php
file, and added this code to my functions.php file:add_filter( 'eventorganiser_bookable_occurrences', function( $bookable, $event_id ) { $now = new DateTime( 'now', eo_get_blog_timezone() ); $bookable = eo_get_the_occurrences_of( $event_id ); foreach( $bookable as $occurrence_id => $occurrence ) { //Remove events whose end date is in the past if ( $now > $occurrence['end'] ) { unset( $bookable[$occurrence_id] ); } } return eo_get_the_occurrences_of( $event_id ); }, 10, 2 );
When I look at a past event, the registration form does not show up. Can you see any errors in the code I tried?
WillowAugust 30, 2016 at 12:34 am #23952Hi Natalie,
Apologies, I missed your reply.
I’ve double checked the above code and it works as expected for me, although it can be shortened too:
add_filter( 'eventorganiser_bookable_occurrences', function( $bookable, $event_id ) { return eo_get_the_occurrences_of( $event_id ); }, 10, 2 );
If that snippet wasn’t working then you should see a message to the effect that the event had sold out or was no longer taking bookings.
If you’re not seeing such a message, and instead are just not seeing a booking form, then it’s probably not the snippet that’s at fault. In that instance it’s likely due to how the tickets have been configured.
For example no form will appear if all tickets have quantity 0 (or there are no more tickets available), or if there are no tickets ‘on sale’ (if you have specified a sale period). Importantly, if selling by date, each of your tickets should have at least one date selected for it to appear on the booking form.
Are you selling by date? And what do you see on the event page?
Stephen Harris -
AuthorPosts