Hello Harris,
I have one problem. For the event I have only one possible ticket but when the form is shown, the quantity is set in form to 0. Many times the customer “send” empty registration and complain after several days that the booking failed.
I try to set in PHP the default value 1 but the value and also the limits are revrited by JS and set back to 0. It hurts me a lot.
Ïs there any simple way how to preset the quantity field to 1?
Second, lower priority question is how to send email to bookie when the booking status is changed (like to Confirmed or to Canceled).
Thanks a lot Kamil
The example of form:
http://www.pghnizdo.cz/events/event/zakladni-kurz-paraglidingu/
Kamil Konečný
Hi Kamil,
For setting the ticket quantity to 1 you can do the following:
<?php
add_action( 'eventorganiser_get_event_booking_form', function( $form, $event_id ){
$tickets = eo_get_event_tickets_on_sale( $event_id );
$ticketpicker = $form->get_element('ticketpicker');
$ticket_insts = array();
$counter = 1;
if ($ticketpicker->get_tickets()) {
return;
}
foreach ( $tickets as $tt_id => $ticket ) {
$ticket_insts[] = ['eocid' => "eoc${counter}", 'type' => $tt_id ];
}
$ticketpicker->set_value($ticket_insts);
}, 10, 2 );
For the second part you can hook into eventorganiser_transition_booking_status
:
add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking) {
//do something when $new_status = 'cancelled' and $old_status ='confirmed'
}, 10, 3);
Stephen Harris
Hello Stephen,
thanks a lot. It works excelent.
I have one more question. I need also block selling more than one ticket per booking, because I have many bookie connected parameters which I miss if he made reservation for more than one person. Is it somehow possible?
Have a nice day Kamil
Kamil Konečný
Hi Kamil,
Apologies, I ddn’t see you reply. You can do this with the following code:
add_action( 'eventorganiser_validate_booking_submission', function( $input, $form, $errors ){
$ticketpicker = $form->get_element( 'ticketpicker' );
$tickets = count($ticketpicker->get_value());
if($tickets > 1) {
$ticketpicker->add_error( 'too_many_tickets', 'You may only book 1 ticket for this event.' );
}
return $input;
}, 20, 3);
Stephen Harris