docs: add missing details for tiered pricing (#12374)

* docs: add missing details for tiered pricing

* adjustments
This commit is contained in:
Shahed Nasser
2025-05-06 14:44:50 +03:00
committed by GitHub
parent f74586e772
commit ea6faa8c82
9 changed files with 14642 additions and 14274 deletions
@@ -193,6 +193,11 @@ const priceSet = await pricingModuleService.createPriceSets({
region_id: "reg_123",
},
},
{
amount: 200,
currency_code: "EUR",
min_quantity: 100,
}
],
})
```
@@ -329,6 +334,83 @@ const priceSet = await pricingModuleService.createPriceSets({
</TabsContentWrapper>
</Tabs>
### Tiered Pricing Selection
<Tabs defaultValue="code">
<TabsList>
<TabsTrigger value="code">Code</TabsTrigger>
<TabsTrigger value="result">Result</TabsTrigger>
</TabsList>
<TabsContentWrapper>
<TabsContent value="code">
```ts
const price = await pricingModuleService.calculatePrices(
{ id: [priceSet.id] },
{
context: {
cart: {
items: [
{
id: "item_1",
quantity: 200,
// assuming the price set belongs to this variant
variant_id: "variant_1",
// ...
}
],
// ...
}
}
}
)
```
</TabsContent>
<TabsContent value="result">
The returned price is:
```ts
const price = {
id: "<PRICE_SET_ID>",
is_calculated_price_price_list: false,
calculated_amount: 200,
is_original_price_price_list: false,
original_amount: 200,
currency_code: "EUR",
is_calculated_price_tax_inclusive: false,
is_original_price_tax_inclusive: false,
calculated_price: {
price_id: "<DEFAULT_PRICE_ID>",
price_list_id: null,
price_list_type: null,
min_quantity: 100,
max_quantity: null,
},
original_price: {
price_id: "<DEFAULT_PRICE_ID>",
price_list_id: null,
price_list_type: null,
min_quantity: 100,
max_quantity: null,
},
}
```
- Original price selection: the fifth price in the price list is selected as the best price because the cart item quantity is 200.
- This is assuming the price set belongs to the cart item's variant.
- Calculated price selection: since there are no associated price lists, the calculated price is set to the original price.
</TabsContent>
</TabsContentWrapper>
</Tabs>
### Price Selection with Price List
<Tabs defaultValue="code">