Check box validation and disable add to cart button when check box not checked in liquid pixel item page

We have got a requirement that to add validation message in liquid pixel item page there we have checkbox to confirm about entered details
If we click add to cart without checking check box user should get validation message for this we have make use of add to cart button functionality and jQuery to display message
Also if personaisation is not selected we can add to cart directly
Here is the code added

  _.extend(CartAddToCartButtonView.prototype, {
                  events: _.extend(
                    {},
                    CartAddToCartButtonView.prototype.events,
                    {
                      'mouseup [data-type="add-to-cart"]': "addToCart",
                      'click [data-type="add-to-cart"]': "addToCart",
                    }
                  ),
                  addToCart: function (e) {
                    try {
                      this.model.isValid("custcol_ag_checkcolors");
                      var isPersonaizable, isPersonalized, isConformedData;

                      if (
                        this.model.get("custcol_ag_havepersonalization") === "T"
                      ) {
                        isPersonaizable = true;
                      }
                      if (isPersonaizable) {
                        isPersonalized = $("#personalize-checkbox")[0].checked;
                        isConformedData = $("#personalized-checkbox")[0]
                          .checked;
                        if (isConformedData) {
                          $("#agree_chk_error").hide();
                        } else {
                          $("#agree_chk_error").show();
                        }
        

Leave a comment

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