Posted: March 9, 2021 at 2:31 pm
|
We have two kinds of tickets – one for logged in users and another for general visitors. We use the Grid View Template on our home page. It can show the total number of available spaces by calling “DTT_reg_limit”. However, we only want to show the number of tickets available for general visitors on the Grid View Template, This way, casual users can see the number of places actually available to them and not the total number of tickets available – which includes tickets only visible to logged-in users. The information we need is available for each ticket type from the “wp_esp_ticket” table via the TKT_qty and TKT_sold fields. Any suggestions on how I might be able to return that data so we can show the number of tickets remaining for each ticket type and only display the relevant number? |
Hi Peter, May I ask, are you using our model system? https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System If not, I recommend taking a look over those docs first as the models make grabbing this data easier, for example, you mentioned Directly from the DB? Or using something like The data you need on the ticket can be shown using Which shows the number of remaining spaces on the ticket assuming You mentioned you have kinds of tickets, so is that always just two tickets within the event? One with a capability set and the other without? |
|
|
Hi Tony, We are modifying the EE Grid View Template which currently calls DTT_reg_limit which appears to link to $datetime->reg_limit();. I have not looked at your model system, but it looks interesting. Do you have any sample code for correctly instantiates $ticket using EE_Ticket? Thanks for taking the time to reply. |
|
Hi Tony, We are modifying the EE Grid View Template which currently calls DTT_reg_limit which appears to link to $datetime->reg_limit();. I have not looked at your model system, but it looks interesting. Do you have any sample code for correctly instantiating $ticket using EE_Ticket? Thanks for taking the time to reply. |
Can you post the code for you grid template to a Gist or Pastebin so I can see what you have so far? For what you are trying to do, use the For example:
Which will return an array of EE_Ticket objects related to that DateTime. Note we have some default where conditions used within the models which can sometimes trip you up when expecting certain objects to be returned. It should affect what you are doing here but worth noting, see HERE.
My recommendation is to use something like Kint Debugger, wrap whatever you are trying to work from in |
|
|
Hi Tony, |
As mentioned, theres a couple of ways to go about this but to give an example for one of them, take a look at this:
That pulls the tickets (actually just one but could easily be changed) related to the datetime in question. It will pull a ‘public’ ticket by default (a ticket that does not have a capability set on it) but if the user is logged in, pulls a ‘member’ ticket (a ticket with a capability set on it). Side note, we don’t provide support for customizations but the above should help give you an idea of how to use the models to get what you need 🙂 |
|
|
This reply has been marked as private. |
You’re most welcome. |
|
The support post ‘Display availability of various ticket types in Grid View Template’ 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.