I have customized the display of our workshops by indicating how many spots are left in a class. I put this in my single-event.php.
<?php
$now = new DateTime( ‘now’, eo_get_blog_timezone() );
if (( eo_get_the_start( DATETIMEOBJ) ) > $now ) {
if( (has_term( ‘Spinning’, ‘event-category’ )) or (has_term(‘Weaving’, ‘event-category’)) or (has_term( ‘Basketry’, ‘event-category’ )) or (has_term(‘Dyeing and Colour’, ‘event-category’) or (has_term(‘Felting’, ‘event-category’)) or (has_term( ‘Fibre Preparation’, ‘event-category’ )))){
//This event is a workshop. Show how many tickets remain
$remaining = eo_get_remaining_tickets_count( get_the_ID() );
if( $remaining > 1 ){
printf( ‘
There are %d spots remaining in this workshop
‘, $remaining);
}elseif( $remaining == 1 ){
echo ‘
Only one spot remaining!
‘;
}elseif( $remaining == 0){
echo ‘
Sorry, this workshop is full. Get on a waiting list.
‘;
}
}
}
?>
However, for events whose registration period is not yet open it still “Sorry, this workshop is full…”
After poking around in the codex and tutorials I still can’t figure out how to ask an event if registration is open. Can you direct me to the right code?
And a question about this code. I pinched some of it from elsewhere. Why use printf for one line and echo for another?
Thanks

Judy Kavanagh
I tend to use printf
when I need to escape values and echo if it’s a hard-coded string.
As for why the above codes does not work for events which don’t have tickets yet, is because eo_get_remaining_tickets_count()
only counts tickets which are currently on sale.
What you could do is, in you single-event.php
is:
$tickets = eo_get_event_tickets_on_sale( get_the_ID() );
If $tickets
is empty then the event has not started yet (or has passed).

Stephen Harris
Thanks Stephen. That works perfectly.

Judy Kavanagh