npm.io
2.22.7 • Published 4d ago

@medusajs/pricing

Licence
MIT
Version
2.22.7
Deps
0
Size
265 kB
Vulns
0
Weekly
0
Stars
36.8K

Medusa logo

@medusajs/pricing

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

Pricing Module for Medusa: manages price sets, prices, price rules, price lists, price list rules, and price preferences. Use it to store prices in multiple currencies, apply rule-based and tiered pricing, run sales or overrides with price lists, and calculate the price that applies in a given context. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.

At a glance

Package @medusajs/pricing
Type Commerce Module
Module key Modules.PRICING ("pricing")
Registered by default Yes
Import from @medusajs/medusa/pricing

Features

  • Store prices per currency in price sets, with quantity tiers and rules.
  • Create price lists for sales and price overrides.
  • Calculate the best price for a context, such as currency, region, or customer group.
  • Configure tax-inclusive pricing with price preferences.

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 createPriceSetStep = createStep(
  "create-price-set",
  async ({}, { container }) => {
    const pricingModuleService = container.resolve(Modules.PRICING)

    const priceSet = await pricingModuleService.createPriceSets({
      prices: [
        {
          amount: 500,
          currency_code: "USD",
        },
      ],
    })

    return new StepResponse({ priceSet }, priceSet.id)
  }
)

Resources