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
@@ -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",
|
||||
|
||||
|
||||
Reference in new issue
Block a user