Support

Home Forums Event Espresso Premium Hide old tickets in Ticket Selector

Hide old tickets in Ticket Selector

Posted: September 6, 2024 at 4:19 am

Viewing 10 reply threads


Gorkem

September 6, 2024 at 4:19 am

I have a problem where old tickets show up in the ticket selector and my current solution is to modify event-espresso-core-reg/modules/ticket_selector/TicketSelectorStandard.php

I’m adding this:

if ($ticket->get_raw('TKT_end_date') < strtotime('-6 months')) {continue;}

At line 107, like this:

// loop through tickets
foreach ($this->tickets as $ticket) {
if ($ticket instanceof EE_Ticket) {
if ($ticket->get_raw('TKT_end_date') < strtotime('-6 months')) {
continue;
}
$this->ticket_rows++;

This works perfectly but of course it’s not a proper solution because it has to be re-applied every time Event Espresso is updated.

Is there a way i can hook into this from my functions.php or a custom plugin (I already use one for adding some translations and so on) so that i’m not hacking about in the core Event Espresso files?


Tony

  • Support Staff

September 6, 2024 at 4:27 am

Hi there,

Can you not just set EE not to display expired tickets?

Event Espresso -> Events -> Templates (tab above the table) -> Ticket Selector Template Settings -> Show Expired Tickets?

Set that to No and remove all expired tickets from the ticket selector in one go.

Side note an ‘expired ticket’ is one where the tickets end date is in the past.


Gorkem

September 6, 2024 at 4:35 am

Hi Tony,

Unfortunately that doesn’t work because we want some expired tickets to be visible. For example, on the second weeks of courses, it’s good for the users to see tickets from the first week as ‘sold out’.


Tony

  • Support Staff

September 6, 2024 at 4:57 am

In that case you can use the FHEE__EventEspresso_modules_ticketSelector_DisplayTicketSelector__getTickets hook to alter the tickets that are available.

Rather than looping over the tickets and working out the dates for those tickets you’ll likely find it more efficient to just query the DB for correct tickets and return to the filter.

We have some details on how to querying datetime fields (the TKT_end_date is a datetime field) here:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-querying.md#querying-datetime-fields

So just add your own where condition to $ticket_query_args and requery the tickets using those args. If you search the current codebase for the above filer you’ll see how this was done there which should help some.


Gorkem

September 6, 2024 at 5:41 am

Hi Tony,

Thank you, but i get a 404 from that link.


Gorkem

September 6, 2024 at 6:14 am

Hi Tony,
AH no worries, i’m not sure why but that link LOOKED correct but for some reason gave me a 404 but i worked backwards to here: https://github.com/eventespresso/event-espresso-core/tree/master/docs

And then forwards to where you were pointing me and got to the document i needed, thank you.


Tony

  • Support Staff

September 6, 2024 at 6:47 am

Oh… weird!

Its the -- in the URL being encoded :S

Heres the link:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G--Model-System/model-querying.md#querying-datetime-fields


Gorkem

September 6, 2024 at 7:35 am

Haha yes, that’s definitely a weird one.
Thank you!


Tony

  • Support Staff

September 6, 2024 at 7:39 am

I’m curious now, did you manage to get this working how you were wanting it to?


Gorkem

October 2, 2024 at 5:42 am

Apologies Tony for the lack of reply.

This is a large project and so i have been covering lots of different aspects. This one, although important is not a show stopper (in that we have a patch we can use as a temporary fix until a proper one is created).

So no, i’ve not managed to get this working yet but I will get back to you if / when i do and i’ll post the solution here too, in case it can help somebody else in the future.


Tony

  • Support Staff

October 2, 2024 at 7:07 am

No problem, thanks for keeping us updated 🙂

Viewing 10 reply threads

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso