Booking Conditional Logik

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 6 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29828

    Hey I have a special question.

    I have very much events.
    Sometimes I need this feature:
    If I book event A also event B should automatic booked?

    Maybe with categories? If one Event of category XY is booked the other events of this category is also booked …

    How can we set up this?

    I have a developer so for advice to realize this would be great.

    Christoph Steinlechner
    #29864

    Hi Christoph,

    What you can do is hook into eventorganiser_transition_booking_status this fires whenever a booking changes status:

     add_action( 'eventorganiser_transition_booking_status', function( $new_status, $old_status, $booking) {
           //Check if $new_status is confirmed
           if('confirmed' !== $new_status) {
               return;
           }
           //Current booking details:
           $event_id = eo_get_booking_meta( $booking->ID, 'event_id', true );
           $occurrence_id = eo_get_booking_meta( $booking->ID, 'occurrence_id', true );
    
           //Create  a new booking:
           $new_booking = array(
               'booking_user' => eo_get_booking_meta($booking->ID, 'bookee', true),
               'booking_status' => 'confirmed',
               'event_id' => 123, 
               'occurrence_id' => 456,
               'ticketinstances'=> array(
                   13 => 1, //1 ticket of type ID 13
               ),
           );
           $new_booking_id = eo_insert_booking( $new_booking );
    
      },10, 3);
    

    The above is just a suggestion, and isn’t by itself a workable solution. There’s a few things to be aware of:

    • Infinite loops (in the above a new confirmed booking is created anytime a booking is confirmed…), you should check for this. Presumably, if the booking is for event B, you wouldn’t create a new booking
      • The above is hooked into booking status changes. An admin could mark a confirmed booking as pending, and then confirm it again. You’ll want to have some sort of check in place that this doesn’t create a second booking for event B.

    If you have any follow up questions, please just let me know.

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