I’m looking for some example code to change the quantity of tickets available in the ticket selector dropdown/s on single event pages. I looked into the templates and found that the dropdowns are generated by espresso_ticket_selector( $post );
So if I have an event ID and a ticket ID how can I change the amount of tickets shown in the dropdown? Eg I have an event ID of 4128 and I want ticket ID 18 to show a max qty of 7 in the dropdown ticket selecter.
Set the max qty for a specific ticket and that’s all that will show in the dropdown for each transaction (if there are that number of tickets available)
Ah okay no worries, so what would be your approach to changing the ticket selector quantity programmatically? I was going to just do it in the template, for example have an if statement and display a different ticket selector conditionally but I’m not sure how to approach that because the selecters are generated by espresso_ticket_selector( $post );
I don’t think you can do this easily, or at least not without completely taking over the output of the ticket selector (which we don’t recommend).
What I would look at doing is using some jQuery to remove the options from the dropdowns after the ticket selector has already been output.
You can use wp_add_inline_script() to add your script only when the ‘ticket_selector’ js script is loaded.
And use wp_localize_script() to pass the event and ticket ID’s which you can then check for in your JS script.
Id recommend creating an issue here, label it as a question and one of our developers may be able to provide details on another way you can do this.
Viewing 5 reply threads
The support post ‘Modify maximum ticket quantities on the fly’ 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.
Support forum for Event Espresso 3 and Event Espresso 4.