Last active
March 31, 2017 16:05
-
-
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.
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 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 ); |
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 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