Skip to content

Commit 2125d61

Browse files
committed
MC-42249: No form validation for negative quantity on bundle products
- Fixed the CR comments
1 parent 8948eee commit 2125d61

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ define([
108108
}
109109

110110
// eslint-disable-next-line no-use-before-define
111-
if (checkIsValidateQty(bundleOption)) {
111+
if (isValidQty(bundleOption)) {
112112
if (changes) {
113113
priceBox.trigger('updatePrice', changes);
114114
}
@@ -136,7 +136,7 @@ define([
136136
optionConfig.qty = field.val();
137137

138138
// eslint-disable-next-line no-use-before-define
139-
if (checkIsValidateQty(optionInstance)) {
139+
if (isValidQty(optionInstance)) {
140140
optionInstance.trigger('change');
141141
}
142142
}
@@ -384,19 +384,17 @@ define([
384384
*
385385
* @param {Object} bundleOption
386386
*/
387-
function checkIsValidateQty(bundleOption) {
388-
var isValid = 0,
387+
function isValidQty(bundleOption) {
388+
var isValid = true,
389389
qtyElem = bundleOption.data('qtyField'),
390-
bundleOptionType = bundleOption.prop('type');
391-
392-
if (bundleOptionType === 'radio' || bundleOptionType === 'select-one') {
393-
if (qtyElem.val() >= qtyElem.data('validate')['validate-item-quantity'].minAllowed &&
394-
qtyElem.val() <= qtyElem.data('validate')['validate-item-quantity'].maxAllowed
395-
) {
396-
isValid = 1;
397-
}
398-
} else {
399-
isValid = 1;
390+
bundleOptionType = bundleOption.prop('type'),
391+
qtyValidator = typeof qtyElem.data('validate') === 'object' ?
392+
qtyElem.data('validate')['validate-item-quantity'] : '';
393+
394+
if (['radio', 'select-one'].includes(bundleOptionType) &&
395+
(qtyElem.val() < qtyValidator.minAllowed || qtyElem.val() > qtyValidator.maxAllowed)
396+
) {
397+
isValid = false;
400398
}
401399

402400
return isValid;

0 commit comments

Comments
 (0)