Support

Home Forums Event Espresso Premium Show number of remaining tickets in ticket selector

Show number of remaining tickets in ticket selector

Posted: March 21, 2023 at 10:27 am


Gorkem

March 21, 2023 at 10:27 am

Hi,

I started a post about this issue back in January but sadly got no response and it has since been closed. I’ve still not been able to find a solution so i decided to try again to see if anyone can point me in the right direction.

I have scoured these forums and gone quite a lot of googling on the subject but unfortunately because of what i’m asking, i seem to find solutions to showing the number of remaining tickets, just not in the location i’m trying to achieve!

What i’m looking to do is, in each row (ticket) of the ticket selector, show how many of that ticket are still available for purchase.

Ideally it would be a new column but it doesn’t have to be.

I do not want to use the “Show details” section (which i have turned off) as there is way more information than i need to show in there but it does seem to contain the information i need, under a column named “remaining”.

Is there a hook that’ll allow me to do this or am i missing something really simple?


Tony

  • Support Staff

March 22, 2023 at 2:32 pm

Hi there,

I started a post about this issue back in January but sadly got no response and it has since been closed.

My sincerest apologies for missing your previous thread, just so you are aware, threads automatically close if no new posts are made so we didn’t intentionally close it out ourselves.

Is there a hook that’ll allow me to do this or am i missing something really simple?

Yes and no.

The short answer to this is there isn’t an easy way to modify the ticket selector output.

There are multiple hooks throughout the ticket selector but none of them will allow you to do what you are requesting easily. The ticket selector has a lot of logic within it and it’s the starting point for all registrations within Event Espresso which means we need to be able to rely on the output of the ticket selector heavily.

Now, it IS possible to customize the output, there are filters within EE that will allow you to load your own template should you wish to do so so you could load your own version of the ticket selector template to whatever you wanted to do. However, we’ve also learnt that when people do that they don’t keep on top of updating that template to match any changes within EE core and apply the changes to their custom templates and then the ticket selector breaks when updates are made as the output now doesn’t match what we expect it to be.

So, with that, I need to prefix this with we don’t provide support for creating your own template or working through issues that arise from loading your own template.

You can force the ticket selector to load your own custom template using a snippet like this:

https://gist.github.com/Pebblo/da3d16507e1baaf53a40

But then you’ll need your own template for the ticket selector.

There are filters in which you can generate individual ticket selector rows:

FHEE__ticket_selector_chart_template__do_ticket_inside_row

and

FHEE__ticket_selector_chart_template__do_ticket_entire_row

However, adding in just an additional column to the table with those isn’t easy (check the codebase for those filters and you’ll see).


Gorkem

March 23, 2023 at 6:21 am

Hi Tony,

No problem! Thank you for your comprehensive reply :^)

I see, it is definitely more complex than is ideal. Can you point me in the direction of how i woudld go about retrieving the number of remaining tickets in a row (in a custom ticket selector template)?

I’m thinking, rather than a unique column, appending a <span> in the quantity row that i can style accordingly would work just fine. It isn’t designed to be there always but instead the idea is to let customers know when there are 5 or less of a ticket, so having it’s own column would actually not be the right way to go anyway.


Tony

  • Support Staff

March 24, 2023 at 5:23 am

EE will already do that although differently than you are looking for.

The qty dropdown will reduce the number of available options you can select as the available Qty decreases.

Can you point me in the direction of how i woudld go about retrieving the number of remaining tickets in a row (in a custom ticket selector template)?

If you have the EE_Ticket object in something like $ticket then you can use $ticket->remaining(); to get the number of remaining tickets available.

Is that what you are looking for?

You could also re-enable the ticket details section and use some JavaScript to pull the value from that into the ‘main’ row. Here is an example a support team member created a while back for this:

https://gist.github.com/joshfeck/0e2e59c39a36b76cc65a3b92f9543c79

You could then just hide the ticket details section from view, you need it enabled for the above snippet to pull the value in from it.


Gorkem

March 27, 2023 at 9:36 am

Hi Tony,

Thanks again for the response :^)
Unfortunately the $ticket->remaining(); route wouldn’t work for what i’m after as i want to pull it in per row of teh actual selector.

But i think the JavaScript option might well be the solution i’ve been looking for. I’m not sure why i didn’t think of that! Thank you very much :^)


Tony

  • Support Staff

March 27, 2023 at 9:40 am

Unfortunately the $ticket->remaining(); route wouldn’t work for what i’m after as i want to pull it in per row of teh actual selector.

I’m not sure why that wouldn’t work then as each row relates to a specific ticket. Meaning you would get the remaining spaces available for the ticket related to the current row.

But i think the JavaScript option might well be the solution i’ve been looking for. I’m not sure why i didn’t think of that! Thank you very much :^)

Awesome, your most welcome.


Gorkem

March 27, 2023 at 10:49 am

I’m not sure why that wouldn’t work then as each row relates to a specific ticket.

Oh, only because it would still rely on me being able to directly affect the template for ticket selector rows and i only found a way to get at the kind of, wrapper template not the individual rows template.

In my case though i think an even simpler solution will work. You mentioned:

The qty dropdown will reduce the number of available options you can select as the available Qty decreases.

Well as i only wnat to flag it up when there are limited numbers left this seems like the perfect place to snatch the remaining number from :^)


Tony

  • Support Staff

March 27, 2023 at 1:48 pm

Oh, only because it would still rely on me being able to directly affect the template for ticket selector rows and i only found a way to get at the kind of, wrapper template not the individual rows template.

Ahh ok, I follow now.

Well as i only wnat to flag it up when there are limited numbers left this seems like the perfect place to snatch the remaining number from :^)

Yeah that should work nicely I think 🙂

The support post ‘Show number of remaining tickets in ticket selector’ 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