Skip to content

Commit 1a74a7d

Browse files
authored
fix: fix handling discount on kit subtotal only with specified quantity
for progressive discount with additional filters
1 parent d34b0cf commit 1a74a7d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

functions/lib/helpers.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,15 @@ const getValidDiscountRules = (discountRules, params, itemsForKit) => {
115115
})
116116
} else if (rule.discount_kit_subtotal) {
117117
value = 0
118+
let totalQuantity = 0
118119
itemsForKit.forEach(item => {
119120
const price = ecomUtils.price(item)
120121
if (price > 0 && checkProductId(item)) {
121122
value += price * item.quantity
123+
totalQuantity += item.quantity
122124
}
123125
})
124126
if (rule.min_quantity > 1) {
125-
const totalQuantity = itemsForKit.reduce((acc, item) => {
126-
return item.quantity + acc
127-
}, 0)
128127
if (totalQuantity > rule.min_quantity) {
129128
value *= (rule.min_quantity / totalQuantity)
130129
}

0 commit comments

Comments
 (0)