This chapter explains how the plugin selects a tier and calculates the final unit price – so you can validate prices and explain them to customers.
Tier matching (step by step)
- Load rules for
product_id+currency_code - Variant scope – prefer variant-specific rules; fall back to product-level (
variant_idempty) - Quantity match – rule applies when
min_qty ≤ quantityand (max_qtyis null ORquantity ≤ max_qty) - Tie-break – if multiple rules match: higher specificity (variant/group/region), then higher
min_qtywins
Rule priority details
Specificity scoring
When several rules qualify, the plugin scores each:
| Factor | Impact |
|---|---|
Exact variant match |
Highest variant score |
Product-level (all variants) |
Lower variant score |
Exact customer group match |
Higher group score |
Exact region match |
Higher region score |
Higher score wins. If scores tie, higher min_qty wins (more specific tier).
Overlapping ranges
Warning Overlapping quantity ranges are allowed but not recommended. When ranges overlap, the tier with the highest min_qty that still fits the quantity wins. Example: Rules 1–50 @ $10 and 25–100 @ $8. At qty 30, both match → $8 wins (higher min_qty).
Price formulas
| Type | Formula |
|---|---|
Fixed |
unit_price = price |
Percentage |
unit_price = base × (1 – price/100) |
Fixed discount |
unit_price = max(base – price, 0) |
Base price (for discount types)
Resolved in this order:
base_unit_pricepassed in Store API request- Medusa variant catalog price for the currency
reference_unit_priceon the rule
If no base is available for a discount tier, calculation may fail or show incomplete preview in Admin.
Rounding & tax
| Topic | Behavior |
|---|---|
Rounding |
Unit prices round to 2 decimal places |
Line total |
unit_price × quantity |
Tax |
Tiers are pre-tax – Medusa handles tax separately |
Edge cases
| Situation | Result |
|---|---|
Quantity 0 or negative |
No match |
No rules for product |
Catalog price only |
Percentage > 100 |
Blocked at creation |
Discount exceeds base |
Unit price floors at $0.00 |
Wrong currency |
Rules for other currencies ignored |
No |
Only product-level rules returned |
Product deleted |
All rules auto-deleted |
Store API
List tiers
GET /store/quantity-pricing?product_id=prod_01XXX&variant_id=variant_01XXX¤cy_code=usdRequires a publishable API key.
Calculate price for quantity
GET /store/quantity-pricing?product_id=prod_01XXX¤cy_code=usd&quantity=25Response includes calculated_price:
{
"quantity_prices": [...],
"calculated_price": {
"unit_price": 90,
"quantity": 25,
"currency_code": "usd",
"rule_id": "qprice_02...",
"pricing_type": "fixed",
"line_total": 2250
}
}Optional parameters
| Parameter | Purpose |
|---|---|
|
Variant-specific rules + fallback |
|
B2B segment |
|
Regional override |
|
Override catalog for discount calculation |
Validation checklist
Before going live, verify:
- Product ID and currency match the rule
- Quantity falls in expected min/max range
- For discount tiers, list price source is correct
- No unintended overlapping tiers
- Variant-specific rules apply to the right SKU