Setting a default ticket quantity

This topic contains 6 replies, has 4 voices, and was last updated by  Stephen Harris 8 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #8217

    Is there a way to set a default starting quantity for the tickets? Right now it all starts at zero, but I would like it to start at 1 just for convenience sake of user having to just click book once they get into page.

    Ronald Friedman
    #8226

    Hi Ronald,

    What’s the particular context? It sounds like you selling only ticket for a non-recurring event (or by series)? If you’re ok to also then limit them to one ticket, you can enable ‘Simple Booking Mode’ (see settings tab of the form customiser).

    If you don’t, then you can copy the template eo-ticket-picker.php (from event-organiser-pro/templates) into your theme and edit it there. Specifically, change the line (~71) from

    <?php  $value = ( isset( $input['tickets'][$ticket_id] ) ? $input['tickets'][$ticket_id] : 0 ); ?>

    to

    <?php  $value = ( isset( $input['tickets'][$ticket_id] ) ? $input['tickets'][$ticket_id] : 1 ); ?>
    Stephen Harris
    #8228

    The second portion worked perfectly and that is what I was looking to do (the template changes on line 71, to modify default from 0 to 1). Thank you!

    • This reply was modified 10 years, 5 months ago by  Ronald Friedman.
    Ronald Friedman
    #8245

    Your welcome 🙂

    Stephen Harris
    #16110

    I moved my template from the plugin’s templates folder into my theme’s directory, and made the change but am not seeing the default quantity change. What do you think is wrong?

    handhugs
    #18197

    I am having the same problem as handhugs with this not updating too.

    I can see the default value is set in the code (see screen grab here: https://www.dropbox.com/s/wwyhkz64ltdqwej/Screen%20Shot%202015-07-31%20at%2017.37.50.png?dl=0) but it still displays as 0. I’ve emptied caches and no change.

    I assume this is being overwritten by JS using the data-eo-ticket-qty attribute but I can see how to control that.

    Any ideas?

    • This reply was modified 8 years, 9 months ago by  David McCourt.
    David McCourt
    #18214

    Hi David,

    The above advice is outdated – and you’re right – this is over-ridden by the javascript. There’s no API exposed for modifying the ticket quantity, however, you can do the following:

    add_action( 'eventorganiser_get_event_booking_form', function( $form_id, $event_id ){
        $tickets = eo_get_event_tickets_on_sale( $event_id );
        if( isset( $_POST['eventorganiser']['booking']['tickets'] ) ) {
               return;
        }
        $_POST['eventorganiser']['booking']['tickets'] = array();
        foreach ( $tickets as $tt_id => $ticket ) {
                //Set default quantity below
                $_POST['eventorganiser']['booking']['tickets'][$tt_id] = 1; 
        }
    }, 10, 2 );
    

    Simply add that to a utilty plug-in or theme’s functions.php

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