Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created May 5, 2017 14:52
Show Gist options
  • Save joshfeck/f19c050bc47682ff30b62202cfcde9d8 to your computer and use it in GitHub Desktop.
Save joshfeck/f19c050bc47682ff30b62202cfcde9d8 to your computer and use it in GitHub Desktop.
EE4 Grid display customization that adds remaining spaces available for an event
if ( $datetime instanceof EE_Datetime ) {
$limit = $datetime->get('DTT_reg_limit');
$remain = $datetime->spaces_remaining( true );
if ( $datetime->sold_out() ) {
$remaintext = '<em>Sold out</em>';
}
if ( $limit == EE_INF ) {
$remaintext = '<em>A lot available</em>';
} else {
$remaintext = sprintf( _nx(
'%1$sOne space available%3$s',
'%1$sThere are %2$s spaces available%3$s',
$remain, 'event ticket info', 'event_espresso' ),
'<em>', $remain, '</em>'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment