fix(promotion): percentage value is accounted for in buyget promotions (#11799)

what:

- allows percentage value to be considered for buy get percentage

FIXES https://github.com/medusajs/medusa/issues/11259
This commit is contained in:
Riqwan Thamir
2025-03-13 18:09:46 +01:00
committed by GitHub
parent 3063d6e601
commit 67b308c8eb
3 changed files with 29 additions and 22 deletions

View File

@@ -200,10 +200,12 @@ export function getComputedActionsForBuyGet(
const appliedPromoValue =
methodIdPromoValueMap.get(item.id) ?? MathBN.convert(0)
const multiplier = MathBN.min(targetItem.quantity, remainingQtyToApply)
const amount = MathBN.mult(
const applicableAmount = MathBN.mult(
MathBN.div(item.subtotal, item.quantity),
multiplier
)
const applicablePercentage = promotion.application_method?.value ?? 100
const amount = MathBN.mult(applicableAmount, applicablePercentage).div(100)
const newRemainingQtyToApply = MathBN.sub(remainingQtyToApply, multiplier)