Skip to content

Commit 318f093

Browse files
committed
fix: properly applying kit discounts on subtotal with proportional quantity
1 parent 5215508 commit 318f093

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

functions/lib/helpers.js

+8
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ const getValidDiscountRules = (discountRules, params, itemsForKit) => {
121121
value += price * item.quantity
122122
}
123123
})
124+
if (rule.min_quantity > 1) {
125+
const totalQuantity = itemsForKit.reduce((acc, item) => {
126+
return item.quantity + acc
127+
}, 0)
128+
if (totalQuantity > rule.min_quantity) {
129+
value *= (totalQuantity / rule.min_quantity)
130+
}
131+
}
124132
}
125133
if (value) {
126134
if (rule.discount && rule.discount.value) {

0 commit comments

Comments
 (0)