how to make checkbox mandatory to work a add to cart button in the pdp page using Jquary

how to make checkbox mandatory to work a add to cart button in the pdp page using Jquary for this we need to use a j quary in the extension

_.extend(ProductDetailsFullView.prototype, {       

            events: {                     

  ‘change #personalized-checkbox’: ‘showAddtoCart’}, showAddtoCart : function (event)

{   if ($(‘#personalized-checkbox’)[0].checked) {                 

$(‘[data-type=”add-to-cart”]’).attr(‘disabled’, false) }

else

{  $(‘[data-type=”add-to-cart”]’).attr(‘disabled’, true)  }   },

we need to add this code in the respective view

_.extend(CartItemActionsView.prototype,

{  getContext: _.wrap(CartItemActionsView.prototype.getContext, function (fn)

{ var originalRet = fn.apply(this, _.toArray(arguments).slice(1));                        //console.log(“originalRet”,originalRet.line.attributes.options.models.length)

  if (originalRet.line.attributes.options.models.length >=5 )

{    var display = true;  }                       

else {  var display = false;  }                       

originalRet.displaypdf = display;   

return originalRet;  })  });
after this code we nee dto give the button if condition

this is one method of making the check box mandatory
thank you .

Leave a comment

Your email address will not be published. Required fields are marked *