Skip to content

Commit d760436

Browse files
committed
MC-42249: No form validation for negative quantity on bundle products
- Fixed the issue for php 7.3 version.
1 parent f93e3ff commit d760436

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ define([
107107
changes = defaultGetOptionValue(bundleOption, this.options.optionConfig);//eslint-disable-line
108108
}
109109

110-
if (changes) {
111-
priceBox.trigger('updatePrice', changes);
110+
if(checkIsValidateQty(bundleOption.data('qtyField'))) {
111+
if (changes) {
112+
priceBox.trigger('updatePrice', changes);
113+
}
114+
this._displayTierPriceBlock(bundleOption);
115+
this.updateProductSummary();
112116
}
113-
114-
this._displayTierPriceBlock(bundleOption);
115-
this.updateProductSummary();
116117
},
117118

118119
/**
@@ -131,12 +132,7 @@ define([
131132
.options[field.data('optionId')]
132133
.selections[field.data('optionValueId')];
133134
optionConfig.qty = field.val();
134-
135-
if (field.val() >= field.data('validate')['validate-item-quantity'].minAllowed &&
136-
field.val() <= field.data('validate')['validate-item-quantity'].maxAllowed
137-
) {
138-
optionInstance.trigger('change');
139-
}
135+
optionInstance.trigger('change');
140136
}
141137
},
142138

@@ -377,6 +373,16 @@ define([
377373
return changes;
378374
}
379375

376+
function checkIsValidateQty(qtyElem) {
377+
var isValid = 0;
378+
if (qtyElem.val() >= qtyElem.data('validate')['validate-item-quantity'].minAllowed &&
379+
qtyElem.val() <= qtyElem.data('validate')['validate-item-quantity'].maxAllowed
380+
) {
381+
isValid = 1;
382+
}
383+
return isValid;
384+
}
385+
380386
/**
381387
* Helper to toggle qty field
382388
* @param {jQuery} element
@@ -455,4 +461,4 @@ define([
455461

456462
return oneItemPrice;
457463
}
458-
});
464+
});

0 commit comments

Comments
 (0)