Support

Home Forums Event Espresso Premium Shortcode – SHOW_REMAINING_TICKETS

Shortcode – SHOW_REMAINING_TICKETS

Posted: June 12, 2020 at 4:08 am


dee4dogs

June 12, 2020 at 4:08 am

Hello again,

We’ve been using the following snippet for a long time, and it’s been working fine.

// Code to lookup and display remaining REQUIRED tickets
function my_print_tickets_left_after_selector($atts) {
global $wpdb;

$EVT_ID = get_the_ID();

//display a title
$x = '<h4>Remaining spaces: ';

$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
if( $event instanceof EE_Event ) {
$required_tickets = $event->tickets(
array(
array(
'TKT_required' => true
)
)
);
if($required_tickets) {
// Loop over all of the required tickets for the event.
foreach($required_tickets as $required_ticket) {
// Sanity check to make sure we have an EE_Ticket.
if($required_ticket instanceof EE_Ticket) {
// Add the spaces remaining for each required ticket to $spaces_remaining.
$remaining_spaces += $required_ticket->remaining();
}
}
}
}

$x .= $remaining_spaces;
$x .= '</h4>';
return $x;

}
add_shortcode('SHOW_REMAINING_TICKETS','my_print_tickets_left_after_selector');

From this thread

As you’ll see from this page, it’s now stopped working. The code still displays the text, but it’s not pulling the number of tickets.

In the event settings, limits are set for both the tickets and the datetimes, and there are still spaces remaining.

Any suggestions on how to fix?
Thans


dee4dogs

June 12, 2020 at 4:11 am

Sorted it.

Realised that the ticket hadn’t been marked as *REQUIRED*.

The support post ‘Shortcode – SHOW_REMAINING_TICKETS’ 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