Support

Home Forums Event Espresso Premium How to add Event Status Conditionals

How to add Event Status Conditionals

Posted: June 11, 2015 at 5:51 pm


HindmanSanchez

June 11, 2015 at 5:51 pm

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!


Dean

June 12, 2015 at 1:05 am

Hi,

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' );
}
?>

replaces

<?php espresso_get_template_part( 'content', 'espresso_events-tickets' ); ?>

and will only show the ticket selector if the event can be registered for.

Some further info on templating in EE4: https://eventespresso.com/wiki/ee4-themes-templates/

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.

Event Espresso