|
1
|
export const metadata = { |
|
2
|
title: `Pricing Concepts`, |
|
3
|
} |
|
4
|
|
|
5
|
# {metadata.title} |
|
6
|
|
|
7
|
In this guide, you’ll learn about the main concepts in the Pricing Module. |
|
8
|
|
|
9
|
## Price Data Model |
|
10
|
|
|
11
|
The [Price](/references/pricing/models/Price) data model represents a specific price for a resource. For example, the price of a product variant in the USD currency. |
|
12
|
|
|
13
|
The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in major units. For example, `$20.00` is stored as `20`, and `$20.5` is stored as `20.5`. |
|
14
|
|
|
15
|
The `Price` data model belongs to other data models like `PriceSet` and `PriceList` to provide a variety of pricing features, as explained below. |
|
16
|
|
|
17
|
--- |
|
18
|
|
|
19
|
## Price Set |
|
20
|
|
|
21
|
A [PriceSet](/references/pricing/models/PriceSet) represents a collection of prices that are linked to a resource. For example, a product variant can have a price set that includes prices in multiple currencies, such as USD and EUR. |
|
22
|
|
|
23
|
Each of these prices is represented by the [Price data model](#price-data-model). |
|
24
|
|
|
25
|
 |
|
26
|
|
|
27
|
--- |
|
28
|
|
|
29
|
## Price List |
|
30
|
|
|
31
|
A [PriceList](/references/pricing/models/PriceList) is a group of prices that are only enabled when their conditions and rules are satisfied. For example, you can apply special prices to customers in the VIP group. |
|
32
|
|
|
33
|
When the conditions are met, the prices in the price list can override the default prices in a price set. Learn more in the [Price Calculation](../price-calculation/page.mdx) guide. |
|
34
|
|
|
35
|
A price list has optional `start_date` and `end_date` properties that indicate the date range in which a price list can be applied. |
|
36
|
|
|
37
|
<Note> |
|
38
|
|
|
39
|
You can store custom data in key-value pairs on a price list using the `metadata` property. This property is available since Medusa [v2.15.0](https://github.com/medusajs/medusa/releases/tag/v2.15.0). |
|
40
|
|
|
41
|
</Note> |
|
42
|
|
|
43
|
Its associated prices are represented by the [Price data model](#price-data-model). |
|
44
|
|
|
45
|
--- |
|
46
|
|
|
47
|
## Multi-Currency Support for Prices |
|
48
|
|
|
49
|
The `Price` data model has a `currency_code` property that represents the currency of the price. For example, `usd` for US Dollars and `eur` for Euros. |
|
50
|
|
|
51
|
This adds support for multi-currency pricing, allowing you to associate a resource with a price set that contains prices in multiple currencies. |
|
52
|
|
|
53
|
For example, Medusa links a product variant from the [Product Module](../../product/page.mdx) to a price set that contains prices in multiple currencies. A variant's price set would be similar to the following: |
|
54
|
|
|
55
|
```json title="Example Price Set with Multiple Currencies" |
|
56
|
{ |
|
57
|
"id": "pset_123", |
|
58
|
"prices": [ |
|
59
|
{ |
|
60
|
"id": "price_123", |
|
61
|
"amount": 20, |
|
62
|
"currency_code": "usd" |
|
63
|
}, |
|
64
|
{ |
|
65
|
"id": "price_124", |
|
66
|
"amount": 18, |
|
67
|
"currency_code": "eur" |
|
68
|
} |
|
69
|
] |
|
70
|
} |
|
71
|
``` |
|
72
|
|
|
73
|
When the customer views and purchases a product, Medusa selects the price based on the customer's currency. |
|
74
|
|
|
75
|
--- |
|
76
|
|
|
77
|
## Multi-Region Support for Prices |
|
78
|
|
|
79
|
The `Price` data model has a relation to the [PriceRule](/references/pricing/models/PriceRule) data model that allows you to define prices that are applied based on specific conditions, such as the customer's region. |
|
80
|
|
|
81
|
For example, Medusa allows you to specify prices for a product variant that are applied only when the customer is in a specific region. The price would be similar to the following: |
|
82
|
|
|
83
|
```json title="Example Price with Region Rule" |
|
84
|
{ |
|
85
|
"id": "price_123", |
|
86
|
"amount": 25, |
|
87
|
"currency_code": "usd", |
|
88
|
"price_rules": [ |
|
89
|
{ |
|
90
|
"id": "pricerule_123", |
|
91
|
"attribute": "region_id", |
|
92
|
"value": "reg_123", |
|
93
|
"operator": "eq" |
|
94
|
} |
|
95
|
] |
|
96
|
} |
|
97
|
``` |
|
98
|
|
|
99
|
When the customer views and purchases a product, Medusa selects the price based on the customer's region. |