One ticket per booking

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #38124

    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:

    Kamil Konečný

    Hi Kamil,

    For setting the ticket quantity to 1 you can do the following:

    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()) {
        foreach ( $tickets as $tt_id => $ticket ) {
            $ticket_insts[] = ['eocid' => "eoc${counter}", 'type' => $tt_id ];
    }, 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
Viewing 4 posts - 1 through 4 (of 4 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.