Need to display remaining tickets

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

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

    Hi,

    I am not familiar enough with php to figure this out on my own (http://codex.wp-event-organiser.com/function-eo_get_remaining_tickets_count.html).

    One of my events is:
    http://katalyst5.com/wp/learn/en/events/event/maximize-your-linkedin-3hrs/

    I want to display the remaining ticket count for each single event in two locations:

    1. As a first bullet in the event Details;
    2. In the booking form, next to the Quantity picker.

    Can you help me?

    Thank you!

    Benoit

    Benoit David
    #18132

    Hi Benoit,

    Are you booking by date or by series? If ‘by date’ then remove the eo_get_the_occurrence_id() below:

    In the event-organiser/templates/single-meta-event-single.php you’ll see:

     <li> <?php eo_the_start($date_format) ?></li>
    

    you can replace that with:

        <?php 
        printf( 
             '<li> %s (Tickets remaining: %d)</li>',
             eo_get_the_start( $date_format ), 
             eo_get_remaining_tickets_count( get_the_ID(), eo_get_the_occurrence_id() )
        );
        ?>
    
    • This reply was modified 9 years, 7 months ago by  Stephen Harris.
    Stephen Harris
    #18134

    Hi Stephen,

    Thanks for the quick response!

    I can only find a file named “event-meta-event-single.php”. Is that the one?

    I found the line to replace, replaced it, but it has no effect.

    Benoit David
    #18148

    Please disregard the question below – Just figured out. It’s the Simple Booking Mode option in the Booking Forms Editor.

    <hr />

    I noticed something else that’s weird. I had put a test ticket of $1 to test my gateways, and after I removed it, the number of ticket selection is gone!

    How can I put it back?

    Thanks!

    • This reply was modified 9 years, 7 months ago by  Benoit David.
    Benoit David
    #18166

    Hi Benoit,

    That’s the one. It should change the display of dates at the top of the page. Can you check the plugin settings (General tab) to ensure templates are enabled.

    Also, if there is a copy of that template in your theme you should make the changes there.

    Stephen Harris
    #18172

    Hi Stephen,

    I got it to work in the event meta. thank you.

    What about in the booking form? I managed to put it right before the Ticket Picker table, but I’d like to append the quantity to the 3rd column (Quantity).

    I think I found the place in eo-ticket-picker.php: the table seems to be create din lines 63 to 80.


    <tr id=”eo-booking-ticket-<?php echo $ticket_id;?>” style=”border-top:none”
    class=”eo-booking-ticket-row <?php echo $class;?>”
    <?php eo_booking_form_ticket_data_attr( $ticket); //Add ticket data attributes – required for JS ?>
    >

                <td class="eo-booking-ticket-name"> <?php echo esc_html( $ticket['name'] ); ?> </td>
                <td class="eo-booking-ticket-price"> <?php echo eo_format_price( $ticket['price'], true ); ?> </td>
                <td class="eo-booking-ticket-qty">
                    <?php  $value = ( isset( $input['tickets'][$ticket_id] ) ? $input['tickets'][$ticket_id] : 0 ); ?>
                    <input type="number"
                        class="<?php echo esc_attr( $this->element->get_class() );?>" 
                        data-eo-ticket-qty="<?php echo esc_attr( $ticket_id );?>" 
                        name="eventorganiser[booking][tickets][<?php echo esc_attr( $ticket_id );?>]" 
                        max="<?php echo $spaces; ?>" style="width:auto;" 
                        min="0" 
                        value="<?php echo esc_attr( $value );?>" />
                </td>
            </tr>
    

    I tried to add it, but it breaks the table.

    The title of the column would become “Quantity/Available” in English and “Quantité/Disponible(s)” in French.
    In each row, the info would be added right after the quantity box, like “/”+ number of tickets left.

    I made a mockup of it: http://www.screencast.com/t/neGO8jLsF

    Is that possible for you to modify the code for me?

    Thank you so much!

    Benoit

    Benoit David
    #18213

    This will only work if selling by series or for single-occurrence events (i.e. when there’s no datepicker involved). But simply add

     $occurrence_tickets = eo_get_the_occurrences_tickets( $event_id );
    

    at the top of the eo-ticket-picker.php

    and then replace

     <input type="number"
          class="<?php echo esc_attr( $this->element->get_class() );?>" 
          data-eo-ticket-qty="<?php echo esc_attr( $ticket_id );?>" 
          name="eventorganiser[booking][tickets][<?php echo esc_attr( $ticket_id );?>]" 
          max="<?php echo $spaces; ?>" style="width:auto;" 
          min="0" 
          value="<?php echo esc_attr( $value );?>" />?>
    

    with

     <input type="number"
          class="<?php echo esc_attr( $this->element->get_class() );?>" 
          data-eo-ticket-qty="<?php echo esc_attr( $ticket_id );?>" 
          name="eventorganiser[booking][tickets][<?php echo esc_attr( $ticket_id );?>]" 
          max="<?php echo $spaces; ?>" style="width:auto;" 
          min="0" 
          value="<?php echo esc_attr( $value );?>" />/<?php echo intval( $spaces );?>
    

    That is, just add

     /<?php echo intval( $spaces );?>
    

    to the end.

    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.