fix(promotion): handle fixed discount type in buy-get promotions#14939
fix(promotion): handle fixed discount type in buy-get promotions#14939kodiakhq[bot] merged 2 commits intomedusajs:developfrom
Conversation
🦋 Changeset detectedLatest commit: ea9132a The changes in this PR will be included in the next version bump. This PR includes changesets to release 77 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@pitzegluck is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
dd20096 to
a51d21d
Compare
a51d21d to
1248119
Compare
|
Thank you for your contribution! 🎉 After an initial review, this PR looks good to us. Here's a summary: ✅ PR template is complete Notes: The 3 new integration tests cover A team member will do a final review before this is merged. We appreciate your patience! |
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
What
Fix buy-get promotions ignoring the fixed discount type.
Why
A merchant setting up "Buy 2, get $5 off the 3rd item" gets a $5 discount treated as 5,000% off instead. The engine ignores
application_method.typeand always runs the percentage formula, despite the promotion model and API supporting thefixedtype for buy-get promotions.How
Branch on
ApplicationMethodType.FIXEDinapplyPromotionToTargetItemsto apply the correct calculation per type, consistent with howshipping-methods.tshandles the same logic. RenameapplicablePercentagetopromotionValueto match sibling file naming (shipping-methods.ts,line-items.ts). Default fallback for missingvaluechanged from100to0to align with sibling conventions.Testing
Added 3 integration tests: basic fixed discount, cap at item price, multi-quantity application. All 89 existing compute-actions tests pass.
Note
The JSDoc examples in
service.tsforcreatePromotionsshow buyget withtype: "fixed"and novaluefield. These examples should be updated separately.Fixes #14934