Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active March 31, 2017 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/3d019689d6c51a302eb95bbd3174b91e to your computer and use it in GitHub Desktop.
Save Pebblo/3d019689d6c51a302eb95bbd3174b91e to your computer and use it in GitHub Desktop.
Example of how to output the available spaces on each datetime of an event.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_dipslay_datetime_spaces( $EVT_ID, $event ) {
if( $event instanceof EE_Event ) {
$datetimes = $event->datetimes();
echo "<ul>";
foreach( $datetimes as $datetime ) {
//How many spaces are available
$spaces_available = $datetime->spaces_remaining();
//Check for infinity and return 'unlimited'
$spaces_available = $spaces_available == EE_INF ? 'unlimited' : $spaces_available;
echo "<li>There are " . $spaces_available . " spaces remaining on datetime: " . $datetime->name() . "</li>";
}
echo "</ul>";
}
}
add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', 'tw_ee_dipslay_datetime_spaces', 10, 2 );
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_dipslay_datetime_spaces2( $event ) {
if( $event instanceof EE_Event ) {
$datetimes = $event->datetimes_ordered( FALSE, FALSE );
echo "<ul>";
foreach( $datetimes as $datetime ) {
//How many spaces are available
$spaces_available = $datetime->spaces_remaining();
//Check for infinity and return 'unlimited'
$spaces_available = $spaces_available == EE_INF ? 'unlimited' : $spaces_available;
echo "<li>There are " . $spaces_available . " spaces remaining on datetime: " . $datetime->name() . "</li>";
}
echo "</ul>";
}
}
add_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', 'tw_ee_dipslay_datetime_spaces2', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment