Support

Home Forums Event Espresso Premium Show 'Sold Out' message in custom widget

Show 'Sold Out' message in custom widget

Posted: June 17, 2016 at 4:42 pm


Nick

June 17, 2016 at 4:42 pm

Hello,

I have code for a custom widget in my functions.php file – I would like to add a message for upcoming events that are sold out. How would I do this?

Thanks,

Nick


Tony

  • Support Staff

June 20, 2016 at 5:23 am

Hi Nick,

So you already have the upcoming events within the widget?

The event object has an is_sold_out() method that you can use to confirm if the event is sold out.

So you can do something like:

$event->is_sold_out( true ) {
    //display sold out message
} else {
    //display something else
}


Nick

July 4, 2016 at 7:54 am

Thanks Tony. I am now not seeing upcoming events that are sold out in the Upcoming Events Widget. Is this the expected behaviour? I was hoping to show the listing for the sold out event as well.


Tony

  • Support Staff

July 5, 2016 at 4:51 am

Is this the custom upcoming events widget or the default one?

The default widget should display the sold out events, if that shows the event but your custom widget does not then its an issue with the code you are using.


Nick

July 5, 2016 at 8:41 am

I am working with the default one at the moment, which isn’t displaying upcoming, but sold out events. Here are a couple of screenshots of the settings:

Screenshot 1

Screenshot 2


Tony

  • Support Staff

July 5, 2016 at 3:09 pm

I’m sorry but you’ve lost me.

With the default widget (as in the upcoming events widget within EE4 that has no modifications to the code at all) you don’t see upcoming events? But you do see sold out events?

Can you link me to the event and somewhere I can view the widget?


Nick

July 5, 2016 at 3:29 pm

No, the other way round. I have two upcoming events – one is sold out and the other is not, and only the non sold out event shows – is this the expected behaviour? I was hoping that the sold out event would show as well, and that I could display a ‘sold out’ message with it (using a customised version of the widget). At present I am just using the default EE4 widget though, with no code modifications. You can see it in the sidebar and the footer on this page: http://opendialogueapproach.co.uk


Tony

  • Support Staff

July 6, 2016 at 7:34 am

So the confusion above is because the default widget does not include sold out events, you’ll need a custom widget that includes sold out events before you can display any message for those.

You’ll need to take a look within the widget around like 306 which should be setting the status of posts to include within the loop, its sets the where condition to only display events with a status of ‘publish’. Sold events have a different status ‘sold_out’ so you’ll need to also include that there.

Once you have the events included in the loop you can use the sold out check I posted above to check if the event is sold out and display any message you prefer.

The support post ‘Show 'Sold Out' message in custom widget’ 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