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*.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  dee4dogs 3 weeks, 6 days ago ago

Topic Tags

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!