Support

Home Forums Event Espresso Premium Limiting quantity of all tickets within an event

Limiting quantity of all tickets within an event

Posted: July 20, 2022 at 12:11 pm

Viewing 6 reply threads


Mike

July 20, 2022 at 12:11 pm

With EE3 and MER, we have used some javascript code you provided for a number of years to enforce a prerequisite ticket within a single event (like one adult before a child’s ticket). I’ve customized that code to enforce initial limits within an event (like one booth but multiple tables and chairs). The situation now is we have a contest with multiple classes (each as an individual ticket) but we need to limit entries to one per class. That works with your code at initial form load, but once one of the classes is selected, all the other classes/tickets now have all the other quantities available again. Is there some way to enforce that individual ticket limit throughout the shopping cart process?

Here’s the code I’m currently using:

<script>
//
// Custom code to limit to 1 honey show entry per class
//
// Honey Show 2022
jQuery(document).ready(function($){
$("select[id='price_id-95'] option[value='2']").remove();
$("select[id='price_id-95'] option[value='3']").remove();
$("select[id='price_id-95'] option[value='4']").remove();
// continuing up to the number of classes...
$("select[id='price_id-95'] option[value='16']").remove();
$("select[id='price_id-95'] option[value='17']").remove();
$("select[id='price_id-95'] option[value='18']").remove();
// refresh cart total
$("#event_espresso_refresh_total").click();

});
</script>


Joao Victor

  • Support Staff

July 25, 2022 at 4:43 pm

Hi there,

I am Joao from the Event Espresso support team.

I apologize you are facing an issue with the Event Espresso 3. I will forward your request to my teammate that will assist you as soon as possible.


Tony

  • Support Staff

July 26, 2022 at 9:17 am

Hi Mike,

Could you link me to the Event in question so I can see what is happening?

You can mark your reply private so only EE staff can view it if needed.


Mike

July 28, 2022 at 4:51 pm

This reply has been marked as private.


Tony

  • Support Staff

July 29, 2022 at 6:57 am

Ok, so what is happening here is EE3 has a feature to update the dropdowns based on the number of spaces available taking into account the current ticket selection.

I cant see a way to work around that other than to edit the file to disable the function (which isn’t really advisable but will get you out of a pinch).

If you are comfortable with FTP you can go to:

\wp-content\plugins\event-espresso\scripts\espresso_cart_functions.js

Open the file and lines 247 – 251 should be something like this:

jQuery('#event_espresso_shopping_cart :input[name^="price_id[' + id + ']"]').each(function(){

    populate_qty_dd(jQuery(this), open_spaces);

});

Add // to the beginning of each line to comment it out. Like so:

//jQuery('#event_espresso_shopping_cart :input[name^="price_id[' + id + ']"]').each(function(){

    //populate_qty_dd(jQuery(this), open_spaces);

//});

How hard fresh your browser and test again.

Does it work then?


Mike

July 29, 2022 at 3:27 pm

Tony, thanks for sharing this solution. Yes, this does work. It does, of course, impact all events and we will have some other events open at the same time. I see that this section of code is part of an IF statement starting at line 224. Expanding the condition to include my two special events, like

        if (me.prop('type') == "select-one" && me.attr('id') != "price_id-95" && me.attr('id') != "price_id-96" ) { //only run the code if a select is modified

seems to work as well. Any unforeseen complications doing it this way? Any better way to write this expanded condition?


Joao Victor

  • Support Staff

August 8, 2022 at 5:46 pm

Hi Mike!

Thanks for getting back to us.

Yes, your code should work fine as well. It’s up to you to choose Tony’s code and yours.

We’re glad it worked!

Viewing 6 reply threads

The support post ‘Limiting quantity of all tickets within an event’ 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