From bbfeb6a88c22c95295d84d2b5cb9fe9b11f97933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= <p.mueller@pcsg.de> Date: Fri, 11 Jun 2021 09:37:03 +0200 Subject: [PATCH] fix: BuyNowBtn -> check required fields before adding to basket --- bin/javascript/controls/BuyNowButton.js | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bin/javascript/controls/BuyNowButton.js b/bin/javascript/controls/BuyNowButton.js index d462950..74a68fe 100644 --- a/bin/javascript/controls/BuyNowButton.js +++ b/bin/javascript/controls/BuyNowButton.js @@ -95,6 +95,33 @@ define('package/quiqqer/template-cologne/bin/javascript/controls/BuyNowButton', ProductElm = this.getElm().getParent('[data-productid]'), ProductControl = QUI.Controls.getById(ProductElm.get('data-quiid')); + if (ProductElm) { + // check require fields + var required = ProductElm.getElements('.product-data-fieldlist [required]'); + + if (required) { + for (var i = 0, len = required.length; i < len; i++) { + if (!required[i].checkValidity()) { + //self.enableQuantityButton(); + self.$Label.setStyle('visibility', 'visible'); + self.addingInProcess = false; + + Loader.destroy(); + this.getElm().set('disabled', false); + this.$Label.setStyle('visibility', 'visible'); + + required[i].focus(); + + // chrome validate message + if ("reportValidity" in required[i]) { + required[i].reportValidity(); + } + return; + } + } + } + } + if ("getFieldControls" in ProductControl) { ProductControl.getFieldControls().each(function (Field) { fields[Field.getFieldId()] = Field.getValue(); -- GitLab