docs: added more details on variant pricing (#4035)
* docs: added more details on variant pricing * Update manage-products.mdx * Update products.md * Update show-products.mdx * shortened down the price details in the admin guide
This commit is contained in:
@@ -389,10 +389,12 @@ If you don’t pass the `handle` body parameter, the handle of the product will
|
||||
|
||||
### Product Variant Prices
|
||||
|
||||
It’s recommended to set the prices of product variants as the actual amount multiplied by a hundred. This behavior is implemented within the Medusa admin, and the Next.js storefront divides all prices by a hundred before displaying the price.
|
||||
For currencies that are not zero-decimal, you must set the prices of product variants as the actual amount multiplied by a hundred.
|
||||
|
||||
So, in the example above, if the `amount` is set to `1000`, it means the price is actually `10`.
|
||||
|
||||
You can learn more about pricing and zero-decimal currencies [here](../products.md#storing-the-product-variants-price).
|
||||
|
||||
---
|
||||
|
||||
## Retrieve a Product
|
||||
|
||||
@@ -105,7 +105,37 @@ The `MoneyAmount` entity has the following attributes that are useful for a prod
|
||||
|
||||
### Storing the Product Variant’s Price
|
||||
|
||||
Although this is no requirement, it’s recommended to store the `amount` as the price multiplied by a hundred. The Medusa admin dashboard and the Next.js storefront expect the price to be of that format, so when prices are displayed they’re divided by a hundred. Also, when you add or update a product variant, its price is sent to the Medusa backend as the price multiplied by a hundred.
|
||||
You must store the `amount` in a currency's smallest unit as an integer.
|
||||
|
||||
For example, if a variant's price is 10 USD, it's stored is `1000`, as in 1,000 cents.
|
||||
|
||||
For zero-decimal currencies, the amount is still stored as an integer without multiplying by a 100. For example, if a variant's price is ¥500, it's stored as `500`.
|
||||
|
||||
<details>
|
||||
<summary>Zero-decimal Currencies</summary>
|
||||
|
||||
- BIF
|
||||
- CLP
|
||||
- DJF
|
||||
- GNF
|
||||
- JPY
|
||||
- KMF
|
||||
- KRW
|
||||
- MGA
|
||||
- PYG
|
||||
- RWF
|
||||
- UGX
|
||||
- VND
|
||||
- VUV
|
||||
- XAF
|
||||
- XOF
|
||||
- XPF
|
||||
|
||||
</details>
|
||||
|
||||
This logic of formatting the price is not handled in the backend. So, when you add a product variant using the Admin APIs, you must format the price as explained earlier. The backend stores the price as received from API requests.
|
||||
|
||||
In addition, the Medusa admin dashboard and the Next.js storefront expect the price to be of that format, so when prices are displayed for currencies that are stored multiplied by a `100`, such as USD, they’re divided by a hundred. Also, when you add or update a product variant, its price is sent to the Medusa backend as the price multiplied by a hundred.
|
||||
|
||||
### Displaying the Product Variant’s Price
|
||||
|
||||
|
||||
@@ -362,13 +362,7 @@ You must pass one of the [pricing parameters](#product-pricing-parameters) to th
|
||||
|
||||
:::
|
||||
|
||||
By default, prices in Medusa are stored as the price entered by the admin multiplied by a 100.
|
||||
|
||||
:::note
|
||||
|
||||
This is the behaviour if you're using the admin dashboard to create products. If you're using a different logic to create products and store prices, you can skip the instructions in this section.
|
||||
|
||||
:::
|
||||
Prices in Medusa are stored as the currency's smallest unit. So, for currencies that are not zero-decimal, the amount is stored multiplied by a `100`. You can learn more about this in the [Product conceptual guide](../products.md#storing-the-product-variants-price).
|
||||
|
||||
So, to show the correct price, you would need to convert it to its actual price with a method like this:
|
||||
|
||||
|
||||
@@ -72,4 +72,5 @@ exceptions:
|
||||
- VIP
|
||||
- UPS
|
||||
- RMA
|
||||
- JSONB
|
||||
- JSONB
|
||||
- USD
|
||||
Reference in New Issue
Block a user