-
-
Save Pebblo/339e8b993769bedc5bec0f84af943098 to your computer and use it in GitHub Desktop.
Example of how to pull the required tickets on an event, combine the remaining tickets values and return.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Please do not include the opneing PHP tag if you already have one. | |
function tw_ee_show_remaining_tickets($atts) { | |
$EVT_ID = get_the_ID(); | |
$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(); | |
} | |
} | |
} | |
return $remaining_spaces; | |
} | |
} | |
add_shortcode('SHOW_REMAINING_TICKETS','tw_ee_show_remaining_tickets'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment