You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The buy-get (buyget) promotion engine ignores the application_method.type field and always calculates the discount as a percentage, even when the type is set to "fixed". This causes wildly incorrect discount amounts when using fixed amount discounts with buyget promotions.
Expected Behavior
When a buyget promotion has application_method.type: "fixed" and value: 50000 (e.g., 50,000 VND), the target item should receive a fixed discount of 50,000 VND per unit.
The admin dashboard edit form allows changing buyget promotions to type: "fixed", and the value is correctly saved to the database — but the compute engine ignores it.
Environment
Medusa version: 2.13.1
@medusajs/promotion version: 2.13.1
Suggested Fix
In buy-get.ts, check promotion.application_method?.type before calculating the amount:
Bug Report
Description
The buy-get (
buyget) promotion engine ignores theapplication_method.typefield and always calculates the discount as a percentage, even when the type is set to"fixed". This causes wildly incorrect discount amounts when using fixed amount discounts with buyget promotions.Expected Behavior
When a buyget promotion has
application_method.type: "fixed"andvalue: 50000(e.g., 50,000 VND), the target item should receive a fixed discount of 50,000 VND per unit.This is consistent with:
type: "fixed"ApplicationMethoddata model which states: "If it's fixed, the promotion discounts a fixed amount"typeviagetPromotionValue()in@medusajs/utils/dist/totals/promotion/index.jsActual Behavior
The engine always calculates:
amount = applicableAmount × value / 100So a
value: 50000withtype: "fixed"is treated as 50,000% discount instead of a fixed 50,000 VND — resulting in an astronomically large discount.Root Cause
In
packages/modules/promotion/src/utils/compute-actions/buy-get.ts, theapplyPromotionToTargetItemsfunction hardcodes percentage calculation:It never reads
promotion.application_method?.typeto determine whether to apply a fixed or percentage calculation.Compare with standard promotions in
@medusajs/utils/src/totals/promotion/index.ts:Standard promotions correctly branch on
type. Buyget does not.Steps to Reproduce
type: "fixed"and a numeric value (e.g.,50000):itemPrice × 50000 / 100instead of50000Additional Context
type: "fixed"totype: "percentage", confirming thatfixedwas not working.type: "fixed", and the value is correctly saved to the database — but the compute engine ignores it.Environment
@medusajs/promotionversion: 2.13.1Suggested Fix
In
buy-get.ts, checkpromotion.application_method?.typebefore calculating the amount: