Posted: June 3, 2020 at 6:11 am
I am using the function included below in my theme’s function.php file. It displays the number of places left for an event or that it is sold out.
Typically I only have one datetime for an event, and the function works fine, but I am now running a weekly group where people can sign up each week and so I have one event with different datetimes. Mostly I have everything set up as I want. I duplicate tickets in advance, associate them with the relevant datetime, and have them ready to go on sale when the current meeting has ended, so that people can book for the next week directly after the meeting.
The function below isn’t working as expected though. The first meeting has now passed and so I would like it to display:
“There are 8 spaces left for this event” (for the new/current datetime which is what shows on the page for the event)
But instead it shows:
“3 June 2020 is now sold out” (for the old event)
Can the function below be adapted so that the information for the current/next datetime is displayed?
If you don’t want that to happen there are multiple methods in The EEM_Datetime model to pull specific datetimes from an event.
Also, a couple of notes for your function, you don’t need this line:
The event is already passed into the filter.
Thanks very much Tony.
and all is working as I hoped. As I am only pulling in one datetime now, the next upcoming one, I didn’t need the ‘foreach’ line.
Thanks also for the other tips about the function. I appreciate that.
You’re most welcome, glad it’s working for you.