Promotion Module

The Promotion Module provides promotion-related features in your Medusa and Node.js applications.

How to Use the Promotion Module's Service#

You can use the Promotion Module's main service by resolving from the Medusa container the resource Modules.PROMOTION imported from @medusajs/framework/utils.

For example:


Features#

Discount Functionalities#

A promotion discounts an amount or percentage of a cart's items, shipping methods, or the entire order.

The Promotion Module allows you to store and manage promotions.

Code
1const promotion = await promotionModuleService.createPromotions({2  code: "10%OFF",3  type: "standard",4  application_method: {5    type: "percentage",6    target_type: "order",7    value: "10",8    currency_code: "usd",9  },10})

Flexible Promotion Rules#

A promotion has rules that restricts when it's applied.

For example, you can create a promotion that's only applied to VIP customers.

Code
1const promotion = await promotionModuleService.createPromotions({2  code: "10%OFF",3  type: "standard",4  application_method: {5    type: "percentage",6    target_type: "order",7    value: "10",8    currency_code: "usd",9  },10  rules: [11    {12      attribute: "customer_group_id",13      operator: "eq",14      values: ["VIP"],15    },16  ],17})

Campaign Management#

A campaign combines promotions under the same conditions, such as start and end dates.

A campaign can also have an identifier for tracking purposes, such as tracking through tools like Google Analytics.

Code
1const campaign = await promotionModuleService.createCampaigns({2  name: "Summer Discounts",3  campaign_identifier: "G-123445",4  starts_at: new Date("2024-05-02"),5  ends_at: new Date("2024-07-20"),6})
Was this page helpful?
Edit this page