-
-
Save Pebblo/bf2dc6c31a806716a3656ba3a8b1df82 to your computer and use it in GitHub Desktop.
Example of how to pull only the required tickets from an event, loop over them all and add their 'remaining' sale values together, then output that value.
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 | |
// EE_Event Object, you should one already but to demo I'm pulling one directly | |
$event = EEM_Event::instance()->get_one_by_ID(1111); | |
// Pull the required tickets for the event. | |
$required_tickets = $event->tickets( array( | |
array('TKT_required' => true) | |
) | |
); | |
// Initialize $remaining_spaces as 0. | |
$remaining_spaces = 0; | |
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(); | |
} | |
} | |
} | |
//Output the number of remaining spaces. | |
echo $remaining_spaces; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment