Created
June 24, 2013 21:50
-
-
Save jwcobb/5853928 to your computer and use it in GitHub Desktop.
Fetch, filter, sort and display TicketGroups form Ticket Evolution API
This file contains hidden or 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
// Set up the TicketEvolution webservice object | |
$tevoWebservice = new TicketEvolution\Webservice($cfg['ticketevolution']['params']); | |
/** | |
* Wrap the entire fetching/listing of tickets in a try/catch for safety | |
*/ | |
try { | |
$options = array( | |
'event_id' => $eventId, | |
); | |
$allTicketGroups = $tevoWebservice->listTicketGroups($options); | |
if (count($allTicketGroups) <= 0) { | |
// No ticketGroups for this event | |
} else { | |
// Filter to just get tickets with a type of "event" | |
$eventTicketGroups = new TicketEvolution\Webservice\ResultSet\Filter\TicketGroups\Event($allTicketGroups); | |
// Sort the "event" ticketGroups | |
$sortOptions = array( | |
'retail_price' => SORT_ASC, | |
'section', // Defaults to SORT_ASC if neither is specified | |
'row' => SORT_DESC, | |
); | |
$eventTicketGroups->sortResults($eventTicketGroups); | |
// Loop through the event tickets | |
foreach ($eventTicketGroups as $eventTicketGroup) { | |
// Display a ticketGroup | |
echo $eventTicketGroup->section . '/' . $eventTicketGroup->row; | |
} | |
} | |
} catch (Exception $e) { | |
// Handle the error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment