• Сообщество
  • Связаться с нами
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаЭкспертыПодберите специалиста для разработки и развития вашего проекта на Medusa
КейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Меч Moscow
Комплексная e-commerce платформа на Medusa для московского fashion-бренда

Меч Moscow · Fashion

Нужна помощь в разработке плагина интеграции для Medusa?

Написать намНайти плагины

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
Q

Quantity pricing rules

Medusa v2 plugin: quantity range pricing engine with admin UI, store API, and PostgreSQL-backed tiers

Нужна доработка этого плагина?

Связаться с нами
npm install @webbycrown/medusa-quantity-pricing-rules
Категория
Другое
Создано
Webbycrown
Версия
1.0.1
Последнее обновление
10 часов назад
Ежемесячные загрузки
0
Звезды на Github
1
npmNPMGitHubGithub

Medusa Quantity Pricing Rules

Medusa v2 plugin for quantity range pricing (volume / tiered / wholesale). Set unit prices by quantity with fixed prices, percentage discounts, or fixed amount-off tiers.

Watch demo: https://www.youtube.com/watch?v=CjBjc7j3H6g

Features

  • PostgreSQL table (module + migrations)
  • Pricing types: , ,
  • Admin API (CRUD + Zod validation) and Store API (list tiers, calculate price)
  • Admin UI: Settings → Extensions → Quantity Pricing, per-product widget, store summary widget
  • Workflows with compensation (create / update / delete)
  • Auto cleanup on
  • Optional variant, region, and customer-group scoping
  • Exported helpers: , catalog utilities, workflows

Requirements

RequirementVersion
Node.js20+
Medusav2.13+ ( ^2.13)

Installation

npm install @webbycrown/medusa-quantity-pricing-rules

Register in :

1import { defineConfig } from "@medusajs/framework/utils"
2
3export default defineConfig({
4 plugins: [
5 {
6 resolve: "@webbycrown/medusa-quantity-pricing-rules",
7 options: {},
8 },
9 ],
10})

Registers the module automatically. Do not add a duplicate entry under .

Run migrations and start Medusa:

1npx medusa db:migrate
2npm run dev

Open Admin → Settings → Extensions → Quantity Pricing to create tiers.

Admin UI

LocationPurpose
Settings → Extensions → Quantity PricingList, create, edit, delete rules
Products → [product]Tiers for that product (product ID pre-filled)
Settings → StoreRule count + link to settings

Tier fields

FieldDescription
Product IDRequired (auto-filled on product page)
VariantOptional — empty = all variants
Min qtyMinimum quantity (e.g. )
Max qtyUpper bound; empty = open-ended (e.g. )
Pricing type, , or
Discount / unit priceSee Pricing types
CurrencyISO 4217, e.g. ,
List price (reference)For discount tiers when catalog price is missing

Non-overlapping ranges per product + currency are recommended. When ranges overlap, the tier with the highest that still fits the quantity wins.

Pricing types

Type meansResolved unit price
Tier unit price
Percent off catalog (e.g. = 10% off)
Amount off per unit

is resolved in order:

  1. on Store API /
  2. Medusa variant catalog price for
  3. on the rule

Store API

— requires a publishable API key.

ParamRequiredDescription
YesProduct to load tiers for
NoVariant-specific rules + product-level fallback
NoFilter / calculation currency
NoB2B segment
NoRegional override
NoWhen set, includes
NoCatalog price for discount tiers
GET /store/quantity-pricing?product_id=prod_01XXXX&currency_code=inr&quantity=25
1{
2 "quantity_prices": [],
3 "calculated_price": {
4 "unit_price": 90,
5 "quantity": 25,
6 "currency_code": "inr",
7 "rule_id": "qprice_02...",
8 "pricing_type": "fixed",
9 "line_total": 2250
10 }
11}

Without , only product-level tiers () are returned.

Admin API

Authenticated admin session or token.

MethodPathDescription
List rules
Create rule
Get rule
Update rule
Delete rule
Variant catalog prices

Create fixed tier:

1{
2 "product_id": "prod_01XXXXXXXX",
3 "min_qty": 1,
4 "max_qty": 10,
5 "pricing_type": "fixed",
6 "price": 100,
7 "currency_code": "inr"
8}

Open-ended tier (51+): set .

Package exports

1import {
2 PRICING_ENGINE_MODULE,
3 resolveQuantityUnitPrice,
4 fetchCatalogPricesForProducts,
5} from "@webbycrown/medusa-quantity-pricing-rules"
6
7const unitPrice = await resolveQuantityUnitPrice(container, {
8 product_id: "prod_01...",
9 variant_id: "variant_01...",
10 quantity: 25,
11 currency_code: "inr",
12 rule_id: "qprice_02...", // optional — pin selected tier
13})
14
15const pricingEngine = container.resolve(PRICING_ENGINE_MODULE)
16const result = await pricingEngine.calculatePrice({
17 product_id: "prod_01...",
18 quantity: 25,
19 currency_code: "inr",
20})
1import {
2 createQuantityPricingRuleWorkflow,
3 updateQuantityPricingRuleWorkflow,
4 deleteQuantityPricingRuleWorkflow,
5} from "@webbycrown/medusa-quantity-pricing-rules/workflows"
ExportPurpose
Container key ()
Module definition
Service class
Resolve tier unit price (cart / checkout)
Batch catalog prices
Base price for a rule
Types, , , …
Create / update / delete workflows

The plugin does not modify cart line items automatically. Use in your add-to-cart flow when a tier applies.

Tier matching

  1. Load rules for (+ optional filters).
  2. Prefer variant-specific rules when is set.
  3. Match and ( is null or ).
  4. Highest matching wins.
  5. Resolve unit price from and base price sources.

Database

Table : , , , , , , , , , .

After model changes in a fork:

1npx medusa db:generate pricingEngine
2npx medusa db:migrate

Troubleshooting

IssueCheck
Admin page not foundRebuild plugin ( in package) and restart Medusa
Empty on storeRules exist for + ; pass if needed
Wrong discount priceVariant catalog price or ; pass
Wrong tierOverlapping ranges — highest wins
Module not foundPlugin under in , not duplicated under

Changelog

See CHANGELOG.md.

Author

WebbyCrown — info@webbycrown.com · webbycrown.com

Еще в этой категории

Посмотреть все
Другое
Gati logo

Gati

От Devx Commerce

Синхронизируйте Medusa с Gati ERP

Загрузка данных
npm
Другое
Product Reviews logo

Product Reviews

От Lambda Curry

Добавляйте рейтинги, отзывы и модерацию товаров

Загрузка данных
GitHubnpm
Другое
Variant Images logo

Variant Images

От Betanoir

Организуйте и загружайте варианты изображений в Medusa

Загрузка данных
GitHubnpm