Support

Home Forums Event Espresso Premium Modify maximum ticket quantities on the fly

Modify maximum ticket quantities on the fly

Posted: December 14, 2017 at 6:10 am

Viewing 5 reply threads


REAIE

December 14, 2017 at 6:10 am

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.


Tony

  • Support Staff

December 14, 2017 at 6:22 am

Hi there,

This is available in the ticket’s advanced options – http://take.ms/4hA9y

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)


REAIE

December 14, 2017 at 1:37 pm

Thanks, Im aware of that but Im looking for an example of changing the value using PHP when I know the event ID and ticket ID in advance.


Josh

  • Support Staff

December 14, 2017 at 2:26 pm

Hi REAIE,

I’m not aware of any example code that does that.


REAIE

December 14, 2017 at 2:55 pm

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 );


Tony

  • Support Staff

December 15, 2017 at 3:55 am

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.

Event Espresso