I have added multiple Customizable Options(e.g. Extra Buffalo Cheese,Extra Aioli,Extra Hollandaise,Extra Caesar Dressing) for products as shown in the image below. I want to restrict this option selection to a maximum to 2 only. basically, the user can select any 2 values for extra not more than two.

Is there a way to achieve this with CMS or through code as I have no idea here ? or Any other better way to do achieve the same.

Customizable Options

1 Answer 1


Copy and override default template in your custom theme app/design/frontend/Your/theme/Magento_Catalog/templates/product/composite/fieldset/options/view/checkable.phtml and add below code at end of file

<script type="text/javascript">
  require(['jquery', 'jquery/ui'], function($){ 
    $('input.product-custom-option').on('change', function(evt) {
       if($('input.product-custom-option').parent().find('input.product-custom-option:checked').length >= 2) {
           $('input.product-custom-option').parent().find('input.product-custom-option:not(:checked)').attr("disabled", true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.