Skip to content

Instantly share code, notes, and snippets.

@Apina
Created February 6, 2015 13:20
Show Gist options
  • Save Apina/6ca2a7fd5ff319d7d10c to your computer and use it in GitHub Desktop.
Save Apina/6ca2a7fd5ff319d7d10c to your computer and use it in GitHub Desktop.
This will display tickets sold / datetime limit. It is an example and currently just lists the data with no formatting. It should be added to the loop of an EE4 Custom Template
if( $event instanceof EE_Event ) {
$spaces_remaining = 0;
$datetimes = $event->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
foreach ( $datetimes as $datetime ) {
if ( $datetime instanceof EE_Datetime ) {
$dtt_spaces_remaining = $datetime->spaces_remaining( TRUE );
// if datetime has unlimited reg limit then the event can never be sold out
if ( $dtt_spaces_remaining === INF ) {
return FALSE;
}
else {
$spaces_remaining = max( $dtt_spaces_remaining, $spaces_remaining );
$max_spaces = $datetime->get_raw( 'DTT_reg_limit' );
}
}
}
echo $post->post_title . ' - ' . $spaces_remaining . ' / ' . $max_spaces . '<br>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment