Skip to main content

Overview

The Promotion Module manages promotional campaigns, discount codes, and automated promotions. It provides rule-based promotion targeting and supports various discount types including percentage, fixed amount, and free shipping. Key Features:
  • Promotional campaigns with budgets
  • Discount codes and automatic promotions
  • Rule-based targeting (customer groups, products, etc.)
  • Multiple application methods (order, item, shipping)
  • Budget tracking and limits
  • Time-based promotions
  • Usage limits per customer
  • Buy X Get Y promotions

When to Use

Use the Promotion Module when you need to:
  • Create discount codes for customers
  • Run promotional campaigns
  • Offer free shipping promotions
  • Implement BOGO (Buy One Get One) offers
  • Target specific customer groups
  • Set promotion budgets and limits
  • Schedule time-limited sales
  • Track promotion usage

Data Models

Promotion

Represents a discount or promotional offer.
string
required
Unique promotion identifier
string
Discount code (e.g., “SUMMER20”)
PromotionType
required
Type: standard, buyget
boolean
required
Whether promotion applies automatically (default: false)
string
ID of the associated campaign
ApplicationMethod
How discount is applied
PromotionRule[]
Targeting rules

ApplicationMethod

Defines how and where a promotion discount applies.
string
required
Unique application method identifier
string
required
Method type: fixed, percentage
string
required
What to discount: order, items, shipping_methods
BigNumber
required
Discount value (amount for fixed, percentage for percentage)
number
Maximum items to discount
number
Number of items to apply discount to
number
Minimum quantity to buy (for buyget promotions)
string
How to allocate: each, across

PromotionRule

Defines targeting conditions for promotions.
string
required
Unique rule identifier
string
required
ID of the promotion
string
required
Rule attribute (e.g., “customer_group_id”, “product_id”)
string
required
Comparison operator: eq, ne, in, gt, gte, lt, lte
PromotionRuleValue[]
required
Rule values to match

Campaign

Groups promotions with budget management.
string
required
Unique campaign identifier
string
required
Campaign name
string
Campaign description
string
Campaign currency code
string
required
Unique campaign identifier (e.g., “summer-2024”)
DateTime
When campaign starts
DateTime
When campaign ends
CampaignBudget
Campaign budget configuration
Promotion[]
Promotions in this campaign

CampaignBudget

Tracks campaign budget and usage.
string
required
Unique budget identifier
string
Budget type: spend, usage
BigNumber
Budget limit
BigNumber
Amount used so far

Service Interface

The Promotion Module service is available at @medusajs/medusa/promotion.

Create Promotion

Create a new promotion.
CreatePromotionDTO | CreatePromotionDTO[]
required
Promotion data
string
Discount code (required for non-automatic promotions)
PromotionType
required
Promotion type: standard, buyget
boolean
Whether promotion applies automatically
CreateApplicationMethodDTO
required
How to apply the discount
CreatePromotionRuleDTO[]
Targeting rules
PromotionDTO | PromotionDTO[]
The created promotion(s)

Create Campaign

Create a promotional campaign with budget.
CreateCampaignDTO | CreateCampaignDTO[]
required
Campaign data
string
required
Campaign name
string
required
Unique identifier
Date
Campaign start date
Date
Campaign end date
CreateCampaignBudgetDTO
Budget configuration

Add Promotion to Campaign

Associate a promotion with a campaign.

Compute Actions

Calculate promotion discounts for a cart or order.
string[]
required
IDs of promotions to compute
object
required
Cart/order context
object[]
Cart or order items
object[]
Shipping methods
object
Customer data
ComputeActionsResult
Computed discount actions

Register Usage

Track promotion usage.

Revert Usage

Revert promotion usage (e.g., on order cancellation).

Promotion Types

Standard Promotions

Basic discount promotions.

Buy X Get Y (BOGO)

Automatic Promotions

Rule Examples

Customer Group Targeting

Product Targeting

Order Value Targeting

Integration Examples

With Cart Module

Apply promotions to cart.

With Customer Module

Customer group promotions.

Best Practices

  1. Code Uniqueness: Promotion codes must be unique. Use descriptive codes that are easy for customers to remember.
  2. Automatic vs Manual: Use automatic promotions for always-on offers (e.g., free shipping over $50). Use codes for targeted campaigns.
  3. Rule Combinations: Rules are AND conditions. All rules must match for a promotion to apply.
  4. Budget Tracking: Set campaign budgets to control promotion costs. Monitor usage regularly.
  5. Target Specificity: Use specific targeting rules to prevent unintended discount application.
  6. Testing: Always test promotions with sample carts before making them active.
  7. Allocation:
    • each: Apply discount to each matching item individually
    • across: Apply total discount split across all matching items