- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Pricing Module
In this section of the documentation, you will find resources to learn more about the Pricing Module and how to use it in your application.
Medusa has pricing related features available out-of-the-box through the Pricing Module. A module is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Pricing Module.
Pricing Features#
- Price Management: Store and manage prices of a resource, such as a product or a variant.
- Advanced Rule Engine: Create prices with custom rules to condition prices based on different contexts.
- Price Lists: Group prices and apply them only in specific conditions with price lists.
- Price Calculation Strategy: Retrieve the best price in a given context and for the specified rule values.
- Tax-Inclusive Pricing: Calculate prices with taxes included in the price, and Medusa will handle calculating the taxes automatically.
How to Use the Pricing Module#
In your Medusa application, you build flows around commerce modules. A flow is built as a Workflow, which is a special function composed of a series of steps that guarantees data consistency and reliable roll-back mechanism.
You can build custom workflows and steps. You can also re-use Medusa's workflows and steps, which are provided by the @medusajs/medusa/core-flows
package.
For example:
1import { 2 createWorkflow, 3 WorkflowResponse,4 createStep,5 StepResponse,6} from "@medusajs/framework/workflows-sdk"7import { Modules } from "@medusajs/framework/utils"8 9const createPriceSetStep = createStep(10 "create-price-set",11 async ({}, { container }) => {12 const pricingModuleService = container.resolve(Modules.PRICING)13 14 const priceSet = await pricingModuleService.createPriceSets({15 prices: [16 {17 amount: 500,18 currency_code: "USD",19 },20 {21 amount: 400,22 currency_code: "EUR",23 min_quantity: 0,24 max_quantity: 4,25 rules: {},26 },27 ],28 })29 30 return new StepResponse({ priceSet }, priceSet.id)31 },32 async (priceSetId, { container }) => {33 if (!priceSetId) {34 return35 }36 const pricingModuleService = container.resolve(Modules.PRICING)37 38 await pricingModuleService.deletePriceSets([priceSetId])39 }40)41 42export const createPriceSetWorkflow = createWorkflow(43 "create-price-set",44 () => {45 const { priceSet } = createPriceSetStep()46 47 return new WorkflowResponse({48 priceSet,49 })50 }51)
You can then execute the workflow in your custom API routes, scheduled jobs, or subscribers:
Learn more about workflows in this documentation.