Unfortunately, our client really doesn’t want the “ticket selector table” that you see on the single events page. Since they are using this plugin for free classes, they felt it was unnecessary to have this feature. Our workaround was to simply remove this with CSS so the registration button would still appear.
When a class is “Sold Out” this removes the registration button (good). However, since the ticket selector has been hidden, there is no text saying “Sold Out”.
I am wondering if there is a PHP conditional in which I can display custom text on “Sold Out” events in the single events template… Is this possible? Thanks in advance for your help!
I’m assuming you are using some of the EE4 template files here.
You could use:
$post->EE_Event->is_active()
Which returns a boolean. It will return false if the event s expired or sold out.
Specifically just for sold out, you could use
$post->EE_Event->perform_sold_out_status_check(), which will return a boolean depending on whether the event is sold out or not.
If you’re not using the template files you will need to locate the nearest variable containing the EE_Event object or instantiate the class.
See /wp-content/plugins/event-espresso-core-reg/core/db_classes/EE_Event.class.php for a list of all the available methods for the EE_Event class.
As an aside, if you are using the template files you could also use one or more of these methods to not show the ticket selector at all, rather than just hiding it with CSS. E.g in the content-espresso_events.php template file:
<?php
if( !$post->EE_Event->is_upcoming() ) {
echo "There are currently no events scheduled";
}
else {
espresso_get_template_part( 'content', 'espresso_events-tickets' );
}
?>
The support post ‘How to add Event Status Conditionals’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.