Support

Home Forums Event Espresso Premium Unhide a div section when all tickets are sold

Unhide a div section when all tickets are sold

Posted: December 8, 2015 at 12:18 pm

Viewing 11 reply threads


Shon Smith

December 8, 2015 at 12:18 pm

is there an easy way to determine how many tickets are left on a specific event? I need to unhide a div section when the event is sold out or there are no more tickets available.
Thanks


Josh

  • Support Staff

December 8, 2015 at 1:08 pm

Hi Shon,

One way is use the espresso_event_status() template tag. It will return the status of the event, so if it’s sold out, you can run the code to display the div.


Shon Smith

December 8, 2015 at 2:14 pm

Thanks Josh, However a little new to wordpress. I have a custom template for the page I want this to apply to, however, need a little help on the syntax to get the status.

Thanks again for your help.
Shon


Josh

  • Support Staff

December 8, 2015 at 3:06 pm

Hi Shon,

Can you post the template code you are working with in a gist or pastebin, and link to it here so we can take a look?


Shon Smith

December 9, 2015 at 6:40 am

Hi Josh,
here is the link: http://pastebin.com/eeTXuXmd

THanks,
Shon


Josh

  • Support Staff

December 9, 2015 at 7:57 am

Hi Shon,

You’re gonna have a better time with something like this instead:

<?php
$event = EEH_Event_View::get_event();
$status = $event instanceof EE_Event ? $event->get_active_status() : 'inactive';
if( $status == 'DTS' ) { ?>
<style>
  #static-scholarship{
      display: none;}
</style>
<?php } ?>


Shon Smith

December 9, 2015 at 8:49 am

Hi Josh,
I have tried the code and it seems like it should work, however, when I do an echo on $status all I get is inactive. I have changed the status of the event from sold out to upcoming, but still nothing. What am I doing wrong?


Josh

  • Support Staff

December 9, 2015 at 9:15 am

Are you using the page template on an event custom post type, or is this a regular WordPress page with a shortcode on it or something?

What you could do is rename your template file to single-espresso_event.php and then click the View event button from the event editor. This way you’ll be viewing the event custom post type post.


Shon Smith

December 9, 2015 at 9:23 am

Yes I am using an wordpress page with a shortcode on it. I am guessing that is my problem. Does the code need to change if I am using a wordpress page?


Josh

  • Support Staff

December 9, 2015 at 9:34 am

Yes because you’re not viewing an event when it’s just a shortcode on a page. The simple way to fix this is use the event custom post type view instead of a WordPress page with a shortcode.

Or you can add the ID of the event to the code like this:

$event = EEH_Event_View::get_event(123);


Shon Smith

December 9, 2015 at 11:01 am

Hi Josh,
I got it to work. Thanks for all your help.
Shon


Josh

  • Support Staff

December 9, 2015 at 11:19 am

You’re welcome Shon.

Viewing 11 reply threads

The support post ‘Unhide a div section when all tickets are sold’ 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