@@ -108,7 +108,7 @@ define([
108
108
}
109
109
110
110
// eslint-disable-next-line no-use-before-define
111
- if ( checkIsValidateQty ( bundleOption ) ) {
111
+ if ( isValidQty ( bundleOption ) ) {
112
112
if ( changes ) {
113
113
priceBox . trigger ( 'updatePrice' , changes ) ;
114
114
}
@@ -136,7 +136,7 @@ define([
136
136
optionConfig . qty = field . val ( ) ;
137
137
138
138
// eslint-disable-next-line no-use-before-define
139
- if ( checkIsValidateQty ( optionInstance ) ) {
139
+ if ( isValidQty ( optionInstance ) ) {
140
140
optionInstance . trigger ( 'change' ) ;
141
141
}
142
142
}
@@ -384,19 +384,17 @@ define([
384
384
*
385
385
* @param {Object } bundleOption
386
386
*/
387
- function checkIsValidateQty ( bundleOption ) {
388
- var isValid = 0 ,
387
+ function isValidQty ( bundleOption ) {
388
+ var isValid = true ,
389
389
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 ;
400
398
}
401
399
402
400
return isValid ;
0 commit comments