docs: document how prices are stored in Medusa (#13362)
This commit is contained in:
1 parent
c71ad3ff61
commit
72675c59ec
6 files changed
+67
-31
No files matched your search
@@ -1893,6 +1893,14 @@ In Medusa v2, the price selection process is now implemented in the [Pricing Mod
|
||||
|
||||
If your use case is complex and these rules are not enough, you can create a new [module](../../fundamentals/modules/page.mdx) with the necessary logic, then use that module in your custom workflows.
|
||||
|
||||
## Prices are Stored in Base Units
|
||||
|
||||
In Medusa v1, prices were stored in the smallest currency unit. For example, a price of $10.00 was stored as `1000` (cents).
|
||||
|
||||
In Medusa v2, prices are stored in the base unit. For example, a price of $10.00 is stored as `10` (dollars).
|
||||
|
||||
Learn more in the [Pricing Concepts](!resources!/commerce-modules/pricing/concepts) guide.
|
||||
|
||||
### Gift Card Features
|
||||
|
||||
Medusa v1 has gift card features out-of-the-box.
|
||||
|
||||
@@ -125,7 +125,7 @@ export const generatedEditDates = {
|
||||
"app/learn/introduction/build-with-llms-ai/page.mdx": "2025-07-22T16:19:11.668Z",
|
||||
"app/learn/installation/docker/page.mdx": "2025-07-23T15:34:18.530Z",
|
||||
"app/learn/fundamentals/generated-types/page.mdx": "2025-07-25T13:17:35.319Z",
|
||||
"app/learn/introduction/from-v1-to-v2/page.mdx": "2025-07-30T08:13:48.592Z",
|
||||
"app/learn/introduction/from-v1-to-v2/page.mdx": "2025-09-01T06:34:41.179Z",
|
||||
"app/learn/debugging-and-testing/debug-workflows/page.mdx": "2025-07-30T13:45:14.117Z",
|
||||
"app/learn/fundamentals/data-models/json-properties/page.mdx": "2025-07-31T14:25:01.268Z",
|
||||
"app/learn/debugging-and-testing/logging/custom-logger/page.mdx": "2025-08-28T15:37:07.328Z",
|
||||
|
||||
@@ -22794,6 +22794,14 @@ In Medusa v2, the price selection process is now implemented in the [Pricing Mod
|
||||
|
||||
If your use case is complex and these rules are not enough, you can create a new [module](https://docs.medusajs.com/learn/fundamentals/modules/index.html.md) with the necessary logic, then use that module in your custom workflows.
|
||||
|
||||
## Prices are Stored in Base Units
|
||||
|
||||
In Medusa v1, prices were stored in the smallest currency unit. For example, a price of $10.00 was stored as `1000` (cents).
|
||||
|
||||
In Medusa v2, prices are stored in the base unit. For example, a price of $10.00 is stored as `10` (dollars).
|
||||
|
||||
Learn more in the [Pricing Concepts](https://docs.medusajs.com/resources/commerce-modules/pricing/concepts/index.html.md) guide.
|
||||
|
||||
### Gift Card Features
|
||||
|
||||
Medusa v1 has gift card features out-of-the-box.
|
||||
@@ -32182,11 +32190,21 @@ View the full flow of the webhook event processing in the [processPaymentWorkflo
|
||||
|
||||
In this document, you’ll learn about the main concepts in the Pricing Module.
|
||||
|
||||
## Price Data Model
|
||||
|
||||
The [Price](https://docs.medusajs.com/references/pricing/models/Price/index.html.md) data model represents a specific price for a resource. For example, the price of a product variant in the USD currency.
|
||||
|
||||
The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base units. For example, `$20.00` is stored as `20`.
|
||||
|
||||
The `Price` data model belongs to other data models like `PriceSet` and `PriceList` to provide a variety of pricing features, as explained below.
|
||||
|
||||
***
|
||||
|
||||
## Price Set
|
||||
|
||||
A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource (for example, a product or a shipping option).
|
||||
A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource (for example, a product variant or a shipping option).
|
||||
|
||||
Each of these prices are represented by the [Price data module](https://docs.medusajs.com/references/pricing/models/Price/index.html.md).
|
||||
Each of these prices is represented by the [Price data model](https://docs.medusajs.com/references/pricing/models/Price/index.html.md).
|
||||
|
||||

|
||||
|
||||
@@ -32622,27 +32640,27 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
prices: [
|
||||
// default price
|
||||
{
|
||||
amount: 500,
|
||||
amount: 5,
|
||||
currency_code: "EUR",
|
||||
rules: {},
|
||||
},
|
||||
// prices with rules
|
||||
{
|
||||
amount: 400,
|
||||
amount: 4,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "reg_123",
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
amount: 4.5,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow",
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 500,
|
||||
amount: 5,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "warsaw",
|
||||
@@ -32650,7 +32668,7 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 200,
|
||||
amount: 2,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 100,
|
||||
},
|
||||
@@ -32707,7 +32725,7 @@ const price = await pricingModuleService.calculatePrices(
|
||||
items: [
|
||||
{
|
||||
id: "item_1",
|
||||
quantity: 200,
|
||||
quantity: 2,
|
||||
// assuming the price set belongs to this variant
|
||||
variant_id: "variant_1",
|
||||
// ...
|
||||
@@ -32738,12 +32756,12 @@ const priceList = pricingModuleService.createPriceLists([{
|
||||
type: "sale",
|
||||
prices: [
|
||||
{
|
||||
amount: 400,
|
||||
amount: 4,
|
||||
currency_code: "EUR",
|
||||
price_set_id: priceSet.id,
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
amount: 4.5,
|
||||
currency_code: "EUR",
|
||||
price_set_id: priceSet.id,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user