Skip to content

Commit 8f780ae

Browse files
ENGCOM-5308: FS/23038 Decimal qty with Increment is with specific values are not adding in cart #23306
- Merge Pull Request #23306 from sertlab/magento2:FS/23038 - Merged commits: 1. 0104df6 2. e80947e
2 parents ef49ac6 + e80947e commit 8f780ae

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/web/mage/validation.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,21 @@
204204
return empty === 0;
205205
}
206206

207+
/**
208+
*
209+
* @param {float} qty
210+
* @param {float} qtyIncrements
211+
* @returns {float}
212+
*/
213+
function resolveModulo(qty, qtyIncrements) {
214+
while (qtyIncrements < 1) {
215+
qty *= 10;
216+
qtyIncrements *= 10;
217+
}
218+
219+
return qty % qtyIncrements;
220+
}
221+
207222
/**
208223
* Collection of validation rules including rules from additional-methods.js
209224
* @type {Object}
@@ -1614,7 +1629,7 @@
16141629
isMaxAllowedValid = typeof params.maxAllowed === 'undefined' ||
16151630
qty <= $.mage.parseNumber(params.maxAllowed),
16161631
isQtyIncrementsValid = typeof params.qtyIncrements === 'undefined' ||
1617-
qty % $.mage.parseNumber(params.qtyIncrements) === 0;
1632+
resolveModulo(qty, $.mage.parseNumber(params.qtyIncrements)) === 0.0;
16181633

16191634
result = qty > 0;
16201635

0 commit comments

Comments
 (0)