Function/action for active/expired tickets

Home Forums Ticket Products Event Tickets Plus Function/action for active/expired tickets

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1515943

    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:

    1. 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)
    2. When a ticket passes expiration date, I may need to flush my caching plugins
      • Thanks

    #1517080
    Victor
    Keymaster

    Hi 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,
    Victor

    #1521027

    Thanks; tribe_events_has_tickets_on_sale() did the trick!

    #1521570
    Victor
    Keymaster

    Happy to be of help! 🙂

    I’ll close this thread now, but feel free to open a new topic if anything comes up.

    Cheers,
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Function/action for active/expired tickets’ is closed to new replies.