@medusajs/promotion
Documentation | Website
Building blocks for digital commerce
Promotion Module for Medusa: manages promotions, promotion rules, application methods, campaigns, and campaign budgets. Use it to create discounts and coupon codes that apply to carts and orders based on rules, and to group them in budget-limited campaigns. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.
At a glance
| Package | @medusajs/promotion |
| Type | Commerce Module |
| Module key | Modules.PROMOTION ("promotion") |
| Registered by default | Yes |
| Import from | @medusajs/medusa/promotion |
Features
- Create standard and buy-get promotions with fixed or percentage discounts.
- Choose whether a buy-get promotion discounts the most expensive or the cheapest eligible items.
- Apply discounts to an order, its items, or its shipping methods.
- Restrict when a promotion applies with rules.
- Group promotions in campaigns with start and end dates and spend or usage budgets.
Installation
No installation needed. The module is included in @medusajs/medusa and registered by default.
Usage
Resolve the module's service from the container, for example in a workflow step:
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const createPromotionStep = createStep(
"create-promotion",
async ({}, { container }) => {
const promotionModuleService = container.resolve(Modules.PROMOTION)
const promotion = await promotionModuleService.createPromotions({
code: "10%OFF",
type: "standard",
application_method: {
type: "percentage",
target_type: "order",
value: 10,
currency_code: "usd",
},
})
return new StepResponse({ promotion }, promotion.id)
}
)