Support

Home Forums Event Espresso Premium Help showing capacity

Help showing capacity

Posted: November 14, 2014 at 10:29 am


Chris Stambaugh

November 14, 2014 at 10:29 am

Hi,

Some nice support person provided me the following code so that I’d have a Shortcode to display the remaining tickets available for an event. The problem is that it works 99% of the time, but occaisionally for some events, it doesn’t work at all and returns erroneous results. An example of this is shown at this page http://www.bsop.ca/edmonton-digital-camera-fundamentals-photography-classes/ which shows the January 10 & 11, 2015 with 13 spots available when it is actually sold out.

The code is here:

function my_print_tickets_left_after_selector($atts) {
    global $wpdb;

$EVT_ID = $atts['evt_id'];

 $x = '';
    $x .= '<ul style="margin-left:0;">';

        $sql = "SELECT DTT_name, DTT_reg_limit, DTT_sold ";
        $sql .= "FROM {$wpdb->prefix}esp_datetime ";
        $sql .= "WHERE {$wpdb->prefix}esp_datetime.EVT_ID = %d";
         
        $datetimes = $wpdb->get_results( $wpdb->prepare( $sql, $EVT_ID ));
         
        foreach($datetimes as $datetime){
            $name = !empty($datetime->DTT_name) ? ($datetime->DTT_name) : 'this event';
            $limit = $datetime->DTT_reg_limit;
            $sold = $datetime->DTT_sold;
            $remainderp = $limit - $sold;
            $remain = $limit == -1 ? '' : $remainderp;
            if ( $limit == $sold ) :
                $x .= '<strong>Sold Out</strong>';
            else :
                $x .= $remain;
            endif;
        }
    $x .= '</ul>';
 
    return $x;
 
}
add_shortcode('show_capacity','my_print_tickets_left_after_selector');

Please help.


Chris Stambaugh

November 14, 2014 at 10:32 am

Forgot a bit of code….

function my_ee_get_ticket_row_template_args( $template_args, $tkt_row, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $creating_event ) {
    if ( ! $creating_event ) {
        return $template_args;
    }
 
    $template_args['TKT_end_date'] = '';
    return $template_args;


Josh

  • Support Staff

November 15, 2014 at 12:47 pm

Hi Paul,

Are you setting the quantity limit to the tickets, the datetimes, or both?


Chris Stambaugh

November 16, 2014 at 10:33 am

Josh,

I’m attaching a screen shot of the edit screen for the event.

I suspect the problem is the two extra tickets (never meant to create them).

The problem is that I can’t change the quantity or delete the tickets. When I click on delete, the tickets temporarily disappear until I click Update/Publish and then they are back.

Also, if I change the event to Private temporarily, I can change the quantities to 0, but then as soon as I make the event public again, the old quantities show up.

Here’s the link to the screen shot.

Argh.


Josh

  • Support Staff

November 17, 2014 at 12:04 pm

Hi Paul,

Can you click the little gear icon on the line of the sold out ticket (the sold out ticket has the yellow indicator on the left side)

Then, can you make sure that the checkbox for Class 1 is checked? This is because the Class 1 is the datetime that has the quantity set.

The custom code that you are using is intended to be used for events that have one datetime. It will also work if an event has more than one date time as long as the tickets are assigned to the datetime that has the quantity set.

The support post ‘Help showing capacity’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso