Pre-defined tickets for each occurrence of an event

WordPress Event Management, Calendars & Registration Forums General Question Pre-defined tickets for each occurrence of an event

This topic contains 4 replies, has 2 voices, and was last updated by  B+eo 9 years, 11 months ago.

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

    I recently bought your pro plugin. It’s awesome and maybe one of the best if not the best event organising or managing plugin for wordpress.

    I read already through http://wp-event-organiser.com/forums/topic/pre-defined-ticket-applied-to-a-new-event/.

    How do I insert pre-defined tickets for each occurrence of one event automatically upon saving the event? Is there a way to accomplish that?

    Thanks, beo

    B+eo
    #16057

    HI beo,

    Do you mean pre-defined ticket available for all occurrences, or each occurrence has it’s own pre-defined ticket (different from other occurrences)?

    Stephen Harris
    #16058

    All occurrences of one event should have the same pre-defined ticket. The tickets don’t differ between multiple occurrences of one event.

    B+eo
    #16082

    I see, well that thread I think covers everything. The first snippet gives an example of how to create a default ticket. Further down there is one to set the occurrences of each of the tickets.

    It would be possible to store a ‘flag’ containing the default ticket ID, so that second snippet only runs once per event, and only for the “default” ticket. But even then, the first time it will over-ride the user’s selection of dates.

    Unfortunately it’ s not possible to create a default ticket for all occurrences, because the occurrences are not yet known (or might, in any case, change).

    A better method might be, to use the snippet in the linked thread, and then if any tickets has no dates associated to it you assume that the user hasn’t specifically selected any dates, and so set the occurrences to all. This would work well if you think there is no good reason why a user would want to create a ticket but not have any dates associated to it.

    The following snippet is adapted from the linked to thread and does what I describe above:

    add_action( 'eventorganiser_save_event', 'my_update_default_tickets', 20 );
    function my_update_default_tickets( $event_id ){
         $occurrences = eo_get_the_occurrences_of( $event_id );
         $occurrence_ids = array_keys( $occurrences );
         $tickets = eo_get_event_tickets( $event_id );
         foreach( $tickets as $ticket_id => $ticket ){
             if( empty(  $ticket['occurrence_ids']  ) ){
                 $ticket['occurrence_ids'] = $occurrence_ids;
             }
             eventorganiser_update_ticket( $ticket_id, $ticket );
         }
    }
    
    Stephen Harris
    #16089

    Actually the other thread really covered everything. Thank you very much for the explanation and for the snippet. I adapted it and it’s working wonderfully.

    I’m still new to the whole wordpress-php-development thing, so I have to read that code three times until I understand … 🙂

    B+eo
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.