• Resolved marco-polo

    (@marco-polo-1)


    In the addon select i would like to require a minimum and a maximum choice.

    ie: pizza > check min 2 ingredients / max 4 ingredients

    For minimum i added a script in post and it’s work:

    <script>
    jQuery('input[type=checkbox]').change(function(e){
       if (jQuery('input[type=checkbox]:checked').length > 4) {
            jQuery(this).prop('checked', false);
       }
    });
    
    </script>

    But i didn’t found for max.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You can add this script, it should work…

    <script>
    jQuery('input[type=checkbox]').change(function(e){
       if (jQuery('input[type=checkbox]:checked').length > 4) {
            jQuery(this).prop('checked', false);
            alert("Check max 4 ingredients");
       }
       if (jQuery('input[type=checkbox]:checked').length < 2) {
            alert("Check min 2 ingredients");
       }
    });
    Thread Starter marco-polo

    (@marco-polo-1)

    Thanks @botwan
    an error in my message, my script is for maximum, not minimum. In my script we can’t checked more than 3 items, it’s ok. I would like add a script for 2 items minimum.
    I think the verification procedure should be done on submit.

      if (jQuery('input[type=checkbox]:checked').length < 2) {
            alert("Check min 2 ingredients");

    No work for minimum, only if i uncheck checkbox i have a alert message. And the problem: i can add only 1 addon in my cart.

    Plugin Contributor Kshirod Patel

    (@kshirod-patel)

    Hello,

    In the future version we will definitely work on this so that admin can easily manage the min and max addon items.

    Thanks,

    That’s great, thx! Keep us updated

    @botwan hey do you mind telling me where you put this code i want to use it too.

    @shearpaladin Add it in the food item page content, using Text mode, NOT Visual mode.

    @botwan sorry I’m not very strong with code. the page with my fooditems?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Script to min/max addon item’ is closed to new replies.