Home › Forums › Ticket Products › Event Tickets Plus › Function/action for active/expired tickets
- This topic has 3 replies, 2 voices, and was last updated 5 years, 12 months ago by ambassadorbaptistcollege.
-
AuthorPosts
-
April 25, 2018 at 9:27 am #1515943ambassadorbaptistcollegeParticipant
Is there any function that I can use to determine whether there are any tickets that have not yet passed their expiration/stop-sale date? In other words, determine whether there are active tickets? I tried https://theeventscalendar.com/function/tribe_events_has_tickets/ but it returns true even if all the tickets have expired.
Alternatively, is there an action hook I could use to run custom code when a ticket does pass its expiration/stop-sale date?
Use cases:
- If there are active tickets, I want to include a “register now” button at the top of the content directing people immediately to the form at the bottom of the page (I know I could move it to the top, but for various usability reasons, I’d like the content first)
- When a ticket passes expiration date, I may need to flush my caching plugins
Thanks
April 26, 2018 at 10:03 am #1517080VictorKeymasterHi Matthew!
Thanks for getting in touch with us!
I’d be happy to help you with this topic.
There is no action hook that triggers when a ticket passes it’s expiration date. However, you can find several useful functions in the following file that will allow you to check if an event has tickets on sale. https://github.com/moderntribe/event-tickets/blob/master/src/template-tags/tickets.php
I’d recommend you try the tribe_events_ticket_is_on_sale() helper function located at https://github.com/moderntribe/event-tickets/blob/master/src/template-tags/tickets.php#L368
Hope that helps.
Best,
VictorMay 2, 2018 at 7:34 am #1521027ambassadorbaptistcollegeParticipantThanks;
tribe_events_has_tickets_on_sale()
did the trick!May 2, 2018 at 5:07 pm #1521570VictorKeymasterHappy to be of help! 🙂
I’ll close this thread now, but feel free to open a new topic if anything comes up.
Cheers,
Victor -
AuthorPosts
- The topic ‘Function/action for active/expired tickets’ is closed to new replies.