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