docs: document how prices are stored in Medusa (#13362)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -6,11 +6,21 @@ export const metadata = {
|
||||
|
||||
In this document, you’ll learn about the main concepts in the Pricing Module.
|
||||
|
||||
## Price Data Model
|
||||
|
||||
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.
|
||||
|
||||
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](/references/pricing/models/PriceSet) represents a collection of prices that are linked to a resource (for example, a product or a shipping option).
|
||||
A [PriceSet](/references/pricing/models/PriceSet) 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](/references/pricing/models/Price).
|
||||
Each of these prices is represented by the [Price data model](/references/pricing/models/Price).
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -166,27 +166,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",
|
||||
@@ -194,7 +194,7 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 200,
|
||||
amount: 2,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 100,
|
||||
},
|
||||
@@ -232,10 +232,10 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
const price = {
|
||||
id: "<PRICE_SET_ID>",
|
||||
is_calculated_price_price_list: false,
|
||||
calculated_amount: 500,
|
||||
calculated_amount: 5,
|
||||
|
||||
is_original_price_price_list: false,
|
||||
original_amount: 500,
|
||||
original_amount: 5,
|
||||
|
||||
currency_code: "EUR",
|
||||
|
||||
@@ -299,10 +299,10 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
const price = {
|
||||
id: "<PRICE_SET_ID>",
|
||||
is_calculated_price_price_list: false,
|
||||
calculated_amount: 500,
|
||||
calculated_amount: 5,
|
||||
|
||||
is_original_price_price_list: false,
|
||||
original_amount: 500,
|
||||
original_amount: 5,
|
||||
|
||||
currency_code: "EUR",
|
||||
|
||||
@@ -353,7 +353,7 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
items: [
|
||||
{
|
||||
id: "item_1",
|
||||
quantity: 200,
|
||||
quantity: 2,
|
||||
// assuming the price set belongs to this variant
|
||||
variant_id: "variant_1",
|
||||
// ...
|
||||
@@ -375,10 +375,10 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
const price = {
|
||||
id: "<PRICE_SET_ID>",
|
||||
is_calculated_price_price_list: false,
|
||||
calculated_amount: 200,
|
||||
calculated_amount: 2,
|
||||
|
||||
is_original_price_price_list: false,
|
||||
original_amount: 200,
|
||||
original_amount: 2,
|
||||
|
||||
currency_code: "EUR",
|
||||
|
||||
@@ -433,12 +433,12 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
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,
|
||||
},
|
||||
@@ -466,10 +466,10 @@ const priceSet = await pricingModuleService.createPriceSets({
|
||||
const price = {
|
||||
id: "<PRICE_SET_ID>",
|
||||
is_calculated_price_price_list: true,
|
||||
calculated_amount: 400,
|
||||
calculated_amount: 4,
|
||||
|
||||
is_original_price_price_list: false,
|
||||
original_amount: 500,
|
||||
original_amount: 5,
|
||||
|
||||
currency_code: "EUR",
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/payment/page.mdx": "2025-04-17T08:48:11.702Z",
|
||||
"app/commerce-modules/pricing/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
|
||||
"app/commerce-modules/pricing/_events/page.mdx": "2024-07-03T19:27:13+03:00",
|
||||
"app/commerce-modules/pricing/concepts/page.mdx": "2024-10-09T13:37:25.678Z",
|
||||
"app/commerce-modules/pricing/price-calculation/page.mdx": "2025-05-20T07:51:40.710Z",
|
||||
"app/commerce-modules/pricing/concepts/page.mdx": "2025-09-01T06:30:15.013Z",
|
||||
"app/commerce-modules/pricing/price-calculation/page.mdx": "2025-09-01T06:32:07.141Z",
|
||||
"app/commerce-modules/pricing/price-rules/page.mdx": "2025-06-10T15:56:43.648Z",
|
||||
"app/commerce-modules/pricing/tax-inclusive-pricing/page.mdx": "2025-06-27T15:43:35.193Z",
|
||||
"app/commerce-modules/pricing/page.mdx": "2025-05-20T07:51:40.710Z",
|
||||
|
||||
Reference in New Issue
Block a user