docs: resdesign and restructure modules references (#5372)
* docs: change format of module reference * description fix * update structure + comments * added new options to README * small text fix * change section ordering * change how required/optional are shown * remove optional text * docs: redesigned accordion
This commit is contained in:
1 parent
3dada88c81
commit
2d74ec256f
218 files changed
+5433
-7683
No files matched your search
-258
@@ -1,258 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/addPrices
|
||||
sidebar_label: addPrices
|
||||
---
|
||||
|
||||
# addPrices - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the addPrices method. This belongs to the Pricing Module.
|
||||
|
||||
## addPrices(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method adds prices to a price set.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An object of type [AddPricesDTO](../../interfaces/AddPricesDTO.md) that holds the data necessary to add the prices. It accepts the following properties:
|
||||
- `priceSetId`: A string indicating the ID of the price set to add prices to.
|
||||
- `prices`: An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to add to the price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: A string that indicates the currency code of this money amount.
|
||||
- `id`: (optional) A string that indicates the ID of the money amount.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the price set that the prices belong to.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addPrices({
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To add prices with rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addPrices({
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
## addPrices(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method adds prices to multiple price sets.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An array of objects of type [AddPricesDTO](../../interfaces/AddPricesDTO.md), each holding the data necessary to add the prices to the price set. Its items accept the following properties:
|
||||
- `priceSetId`: A string indicating the ID of the price set to add prices to.
|
||||
- `prices`: An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to add to the price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: A string that indicates the currency code of this money amount.
|
||||
- `id`: (optional) A string that indicates the ID of the money amount.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), each being a price list that prices were added to.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addPrices([{
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To add prices with rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addPrices([{
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/addPrices
|
||||
sidebar_label: addPrices
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# addPrices - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `addPrices` method. This belongs to the Pricing Module.
|
||||
|
||||
## addPrices(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method adds prices to a price set.
|
||||
|
||||
### Example
|
||||
|
||||
To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addPrices({
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To add prices with rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addPrices({
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`AddPricesDTO`](../../interfaces/AddPricesDTO.mdx)","description":"The data defining the price set to add the prices to, along with the prices to add.","optional":false,"defaultValue":"","children":[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add prices to.","optional":false,"defaultValue":"","children":[]},{"name":"prices","type":"[`CreatePricesDTO`](../../interfaces/CreatePricesDTO.mdx)[]","description":"The prices to add to the price set.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The price set that the prices were added to.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
|
||||
## addPrices(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method adds prices to multiple price sets.
|
||||
|
||||
### Example
|
||||
|
||||
To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addPrices([{
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To add prices with rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addPricesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addPrices([{
|
||||
priceSetId,
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`AddPricesDTO`](../../interfaces/AddPricesDTO.mdx)[]","description":"The data defining the prices to add per price set.","optional":false,"defaultValue":"","children":[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add prices to.","optional":false,"defaultValue":"","children":[]},{"name":"prices","type":"[`CreatePricesDTO`](../../interfaces/CreatePricesDTO.mdx)[]","description":"The prices to add to the price set.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of the price sets that prices were added to.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-144
@@ -1,144 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/addRules
|
||||
sidebar_label: addRules
|
||||
---
|
||||
|
||||
# addRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the addRules method. This belongs to the Pricing Module.
|
||||
|
||||
## addRules(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method adds rules to a price set.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An object of type [AddRulesDTO](../../interfaces/AddRulesDTO.md) that holds the necessary data to add rules to a price set. It accepts the following properties:
|
||||
- `priceSetId`: A string indicating the ID of the price set to add the rules to.
|
||||
- `rules`: An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the price set that the rules belong to.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addRulesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addRules({
|
||||
priceSetId,
|
||||
rules: [{
|
||||
attribute: "region_id"
|
||||
}]
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
## addRules(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method adds rules to multiple price sets.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An array of objects of type [AddRulesDTO](../../interfaces/AddRulesDTO.md), each holding the necessary data to add rules to a price set. Its items accept the following properties:
|
||||
- `priceSetId`: A string indicating the ID of the price set to add the rules to.
|
||||
- `rules`: An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), each being the price set that rules were added to.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addRulesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addRules([{
|
||||
priceSetId,
|
||||
rules: [{
|
||||
attribute: "region_id"
|
||||
}]
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/addRules
|
||||
sidebar_label: addRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# addRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `addRules` method. This belongs to the Pricing Module.
|
||||
|
||||
## addRules(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method adds rules to a price set.
|
||||
|
||||
### Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addRulesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.addRules({
|
||||
priceSetId,
|
||||
rules: [{
|
||||
attribute: "region_id"
|
||||
}]
|
||||
})
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`AddRulesDTO`](../../interfaces/AddRulesDTO.mdx)","description":"The data defining the price set to add the rules to, along with the rules to add.","optional":false,"defaultValue":"","children":[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add the rules to.","optional":false,"defaultValue":"","children":[]},{"name":"rules","type":"{ `attribute`: `string` }[]","description":"The rules to add to a price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The price set that the rules were added to.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
|
||||
## addRules(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method adds rules to multiple price sets.
|
||||
|
||||
### Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function addRulesToPriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.addRules([{
|
||||
priceSetId,
|
||||
rules: [{
|
||||
attribute: "region_id"
|
||||
}]
|
||||
}])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`AddRulesDTO`](../../interfaces/AddRulesDTO.mdx)[]","description":"The data defining the rules to add per price set.","optional":false,"defaultValue":"","children":[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add the rules to.","optional":false,"defaultValue":"","children":[]},{"name":"rules","type":"{ `attribute`: `string` }[]","description":"The rules to add to a price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of the price sets that the rules were added to.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/calculatePrices
|
||||
sidebar_label: calculatePrices
|
||||
---
|
||||
|
||||
# calculatePrices - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the calculatePrices method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to calculate prices based on the provided filters and context.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: An object of type [PricingFilters](../../interfaces/PricingFilters.md) used to filter the price sets. It accepts the following properties:
|
||||
- `id`: An array of strings, each being an ID of a price set.
|
||||
- `context`: (optional) An object of type [PricingContext](../../interfaces/PricingContext.md) to select prices. For example, the pricing context can specify the currency code to calculate prices in. It accepts the following properties:
|
||||
- `context`: (optional) an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [CalculatedPriceSetDTO](../../interfaces/CalculatedPriceSetDTO.md) which includes the calculated prices.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CalculatedPriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: a number indicating the calculated amount. It can possibly be `null` if there's no price set up for the provided context.
|
||||
- `currency_code`: a string indicating the currency code of the calculated price. It can possibly be `null`.
|
||||
- `id`: a string indicating the ID of the price set.
|
||||
- `max_quantity`: a number indicaitng the maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.
|
||||
- `min_quantity`: a number indicaitng the minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
async function calculatePrice (priceSetId: string, currencyCode: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const price = await pricingService.calculatePrices(
|
||||
{ id: [priceSetId] },
|
||||
{
|
||||
context: {
|
||||
currency_code: currencyCode
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price or return it
|
||||
}
|
||||
```
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/calculatePrices
|
||||
sidebar_label: calculatePrices
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# calculatePrices - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `calculatePrices` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to calculate prices based on the provided filters and context.
|
||||
|
||||
## Example
|
||||
|
||||
When you calculate prices, you must at least specify the currency code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
async function calculatePrice (priceSetId: string, currencyCode: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const price = await pricingService.calculatePrices(
|
||||
{ id: [priceSetId] },
|
||||
{
|
||||
context: {
|
||||
currency_code: currencyCode
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price or return it
|
||||
}
|
||||
```
|
||||
|
||||
To calculate prices for specific minimum and/or maximum quantity:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
async function calculatePrice (priceSetId: string, currencyCode: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const price = await pricingService.calculatePrices(
|
||||
{ id: [priceSetId] },
|
||||
{
|
||||
context: {
|
||||
currency_code: currencyCode,
|
||||
min_quantity: 4
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price or return it
|
||||
}
|
||||
```
|
||||
|
||||
To calculate prices for custom rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
async function calculatePrice (priceSetId: string, currencyCode: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const price = await pricingService.calculatePrices(
|
||||
{ id: [priceSetId] },
|
||||
{
|
||||
context: {
|
||||
currency_code: currencyCode,
|
||||
region_id: "US"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`PricingFilters`](../../interfaces/PricingFilters.mdx)","description":"The filters to apply on prices.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`[]","description":"IDs to filter prices.","optional":false,"defaultValue":"","children":[]}]},{"name":"context","type":"[`PricingContext`](../../interfaces/PricingContext.mdx)","description":"The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value will be retrieved.","optional":true,"defaultValue":"","children":[{"name":"context","type":"Record<`string`, `string` \\| `number`\\>","description":"an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`CalculatedPriceSetDTO`](../../interfaces/CalculatedPriceSetDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The calculated price matching the context and filters provided.","children":[{"name":"CalculatedPriceSetDTO","type":"`object`","description":"A calculated price set's data.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"``null`` \\| `number`","description":"The calculated amount. It can possibly be `null` if there's no price set up for the provided context.","optional":false,"defaultValue":"","children":[]},{"name":"currency_code","type":"``null`` \\| `string`","description":"The currency code of the calculated price. It can possibly be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"``null`` \\| `number`","description":"The maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"min_quantity","type":"``null`` \\| `number`","description":"The minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-273
@@ -1,273 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/create
|
||||
sidebar_label: create
|
||||
---
|
||||
|
||||
# create - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the create method. This belongs to the Pricing Module.
|
||||
|
||||
## create(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method is used to create a new price set.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An object of type [CreatePriceSetDTO](../../interfaces/CreatePriceSetDTO.md) that holds the attribute of the price set to create. It accepts the following properties:
|
||||
- `prices`: (optional) An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to associate with the price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: A string that indicates the currency code of this money amount.
|
||||
- `id`: (optional) A string that indicates the ID of the money amount.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
- `rules`: (optional) An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. This property is used to specify the rule types associated with the price set.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the created price set.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
To create a default price set, don't pass any rules. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSet () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.create(
|
||||
{
|
||||
rules: [],
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "USD",
|
||||
min_quantity: 5,
|
||||
max_quantity: 10,
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To create a price set and associate it with rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSet () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.create(
|
||||
{
|
||||
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
## create(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method is used to create multiple price sets.
|
||||
|
||||
### Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreatePriceSetDTO](../../interfaces/CreatePriceSetDTO.md), where each object holds the attribute of a price set to create. Its items accept the following properties:
|
||||
- `prices`: (optional) An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to associate with the price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: A string that indicates the currency code of this money amount.
|
||||
- `id`: (optional) A string that indicates the ID of the money amount.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
- `rules`: (optional) An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. This property is used to specify the rule types associated with the price set.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
### Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which are the created price sets.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
### Example
|
||||
|
||||
To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSets () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.create([
|
||||
{
|
||||
rules: [],
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To create price sets and associate them with rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSets () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.create([
|
||||
{
|
||||
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/create
|
||||
sidebar_label: create
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# create - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `create` method. This belongs to the Pricing Module.
|
||||
|
||||
## create(data, sharedContext?): Promise<PriceSetDTO\>
|
||||
|
||||
This method is used to create a new price set.
|
||||
|
||||
### Example
|
||||
|
||||
To create a default price set, don't pass any rules. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSet () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.create(
|
||||
{
|
||||
rules: [],
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "USD",
|
||||
min_quantity: 5,
|
||||
max_quantity: 10,
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To create a price set and associate it with rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSet () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.create(
|
||||
{
|
||||
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreatePriceSetDTO`](../../interfaces/CreatePriceSetDTO.mdx)","description":"The attributes of the price set to create.","optional":false,"defaultValue":"","children":[{"name":"prices","type":"[`CreatePricesDTO`](../../interfaces/CreatePricesDTO.mdx)[]","description":"The prices to create and add to this price set.","optional":true,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The created price set.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
|
||||
## create(data, sharedContext?): Promise<PriceSetDTO[]\>
|
||||
|
||||
This method is used to create multiple price sets.
|
||||
|
||||
### Example
|
||||
|
||||
To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSets () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.create([
|
||||
{
|
||||
rules: [],
|
||||
prices: [
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To create price sets and associate them with rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSets () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.create([
|
||||
{
|
||||
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
|
||||
prices: [
|
||||
{
|
||||
amount: 300,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
region_id: "PL",
|
||||
city: "krakow"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4,
|
||||
rules: {
|
||||
region_id: "PL"
|
||||
},
|
||||
},
|
||||
{
|
||||
amount: 450,
|
||||
currency_code: "EUR",
|
||||
rules: {
|
||||
city: "krakow"
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreatePriceSetDTO`](../../interfaces/CreatePriceSetDTO.mdx)[]","description":"The price sets to create.","optional":false,"defaultValue":"","children":[{"name":"prices","type":"[`CreatePricesDTO`](../../interfaces/CreatePricesDTO.mdx)[]","description":"The prices to create and add to this price set.","optional":true,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
### Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created price sets.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createCurrencies
|
||||
sidebar_label: createCurrencies
|
||||
---
|
||||
|
||||
# createCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the createCurrencies method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new currencies.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreateCurrencyDTO](../../interfaces/CreateCurrencyDTO.md), each object holding the data of a currency to create. Its items accept the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: a string indicating the name of the currency.
|
||||
- `symbol`: a string indicating the symbol of the currency.
|
||||
- `symbol_native`: a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md), each object being a created currency.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CurrencyDTO
|
||||
</summary>
|
||||
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.createCurrencies([
|
||||
{
|
||||
code: "USD",
|
||||
symbol: "$",
|
||||
symbol_native: "$",
|
||||
name: "US Dollar",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createCurrencies
|
||||
sidebar_label: createCurrencies
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# createCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `createCurrencies` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new currencies.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.createCurrencies([
|
||||
{
|
||||
code: "USD",
|
||||
symbol: "$",
|
||||
symbol_native: "$",
|
||||
name: "US Dollar",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)[]","description":"The currencies to create.","optional":false,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createMoneyAmounts
|
||||
sidebar_label: createMoneyAmounts
|
||||
---
|
||||
|
||||
# createMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the createMoneyAmounts method. This belongs to the Pricing Module.
|
||||
|
||||
This method creates money amounts.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreateMoneyAmountDTO](../../interfaces/CreateMoneyAmountDTO.md) that holds the necessary data to create the money amount. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: A string that indicates the currency code of this money amount.
|
||||
- `id`: (optional) A string that indicates the ID of the money amount.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), each being a created money amount.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
MoneyAmountDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.createMoneyAmounts([
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "USD",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createMoneyAmounts
|
||||
sidebar_label: createMoneyAmounts
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# createMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `createMoneyAmounts` method. This belongs to the Pricing Module.
|
||||
|
||||
This method creates money amounts.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.createMoneyAmounts([
|
||||
{
|
||||
amount: 500,
|
||||
currency_code: "USD",
|
||||
},
|
||||
{
|
||||
amount: 400,
|
||||
currency_code: "USD",
|
||||
min_quantity: 0,
|
||||
max_quantity: 4
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreateMoneyAmountDTO`](../../interfaces/CreateMoneyAmountDTO.mdx)[]","description":"The money amounts to create.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](../../interfaces/CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createPriceRules
|
||||
sidebar_label: createPriceRules
|
||||
---
|
||||
|
||||
# createPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the createPriceRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new price rules based on the provided data.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreatePriceRuleDTO](../../interfaces/CreatePriceRuleDTO.md), each containing the data necessary to create a price rule. Its items accept the following properties:
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: (optional) A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: (optional) A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md), each being a created price rule.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceRuleDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceRules (
|
||||
id: string,
|
||||
priceSetId: string,
|
||||
ruleTypeId: string,
|
||||
value: string,
|
||||
priceSetMoneyAmountId: string,
|
||||
priceListId: string
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.createPriceRules([
|
||||
{
|
||||
id,
|
||||
price_set_id: priceSetId,
|
||||
rule_type_id: ruleTypeId,
|
||||
value,
|
||||
price_set_money_amount_id: priceSetMoneyAmountId,
|
||||
price_list_id: priceListId
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createPriceRules
|
||||
sidebar_label: createPriceRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# createPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `createPriceRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new price rules based on the provided data.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceRules (
|
||||
id: string,
|
||||
priceSetId: string,
|
||||
ruleTypeId: string,
|
||||
value: string,
|
||||
priceSetMoneyAmountId: string,
|
||||
priceListId: string
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.createPriceRules([
|
||||
{
|
||||
id,
|
||||
price_set_id: priceSetId,
|
||||
rule_type_id: ruleTypeId,
|
||||
value,
|
||||
price_set_money_amount_id: priceSetMoneyAmountId,
|
||||
price_list_id: priceListId
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreatePriceRuleDTO`](../../interfaces/CreatePriceRuleDTO.mdx)[]","description":"The price rules to create.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price rule.","optional":false,"defaultValue":"","children":[]},{"name":"price_list_id","type":"`string`","description":"The ID of the associated price list.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`","description":"The ID of the associated price set.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`","description":"The ID of the associated price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"priority","type":"`number`","description":"The priority of the price rule in comparison to other applicable price rules.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`","description":"The ID of the associated rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price rule.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createPriceSetMoneyAmountRules
|
||||
sidebar_label: createPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# createPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the createPriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and
|
||||
a rule type.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreatePriceSetMoneyAmountRulesDTO](../../interfaces/CreatePriceSetMoneyAmountRulesDTO.md), each containing the data of a price set money amount rule to create. Its items accept the following properties:
|
||||
- `price_set_money_amount`: A string indicating the ID of a price set money amount.
|
||||
- `rule_type`: A string indicating the ID of a rule type.
|
||||
- `value`: A string indicating the value of the price set money amount rule.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md), each being
|
||||
a created price set money amount rule.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetMoneyAmountRulesDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount.
|
||||
- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties:
|
||||
- `id`: a string indicating the ID of a price set money amount.
|
||||
- `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set.
|
||||
- `title`: (optional) a string indicating the title of the price set money amount.
|
||||
- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `value`: a string indicating the value of the price set money amount rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSetMoneyAmountRules (priceSetMoneyAmountId: string, ruleTypeId: string, value: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.createPriceSetMoneyAmountRules([
|
||||
{
|
||||
price_set_money_amount: priceSetMoneyAmountId,
|
||||
rule_type: ruleTypeId,
|
||||
value
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createPriceSetMoneyAmountRules
|
||||
sidebar_label: createPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# createPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `createPriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and
|
||||
a rule type.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createPriceSetMoneyAmountRules (priceSetMoneyAmountId: string, ruleTypeId: string, value: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.createPriceSetMoneyAmountRules([
|
||||
{
|
||||
price_set_money_amount: priceSetMoneyAmountId,
|
||||
rule_type: ruleTypeId,
|
||||
value
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreatePriceSetMoneyAmountRulesDTO`](../../interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx)[]","description":"The price set money amount rules to create.","optional":false,"defaultValue":"","children":[{"name":"price_set_money_amount","type":"`string`","description":"The ID of a price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"`string`","description":"The ID of a rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price set money amount rule.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createRuleTypes
|
||||
sidebar_label: createRuleTypes
|
||||
---
|
||||
|
||||
# createRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the createRuleTypes method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new rule types.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [CreateRuleTypeDTO](../../interfaces/CreateRuleTypeDTO.md), each being the data to use to create a rule type. Its items accept the following properties:
|
||||
- `default_priority`: (optional) A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: (optional) A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), each being a created rule type.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
RuleTypeDTO
|
||||
</summary>
|
||||
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createRuleTypes () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.createRuleTypes([
|
||||
{
|
||||
name: "Region",
|
||||
rule_attribute: "region_id"
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/createRuleTypes
|
||||
sidebar_label: createRuleTypes
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# createRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `createRuleTypes` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to create new rule types.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function createRuleTypes () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.createRuleTypes([
|
||||
{
|
||||
name: "Region",
|
||||
rule_attribute: "region_id"
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`CreateRuleTypeDTO`](../../interfaces/CreateRuleTypeDTO.mdx)[]","description":"The rule types to create.","optional":false,"defaultValue":"","children":[{"name":"default_priority","type":"`number`","description":"The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the rule type.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The display name of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`","description":"The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of created rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/delete
|
||||
sidebar_label: delete
|
||||
---
|
||||
|
||||
# delete - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the delete method. This belongs to the Pricing Module.
|
||||
|
||||
This method deletes price sets by their IDs.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `ids`: An array of strings, each being the ID for a price set to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves when the price sets are successfully deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function removePriceSetRule (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.delete(priceSetIds)
|
||||
}
|
||||
```
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/delete
|
||||
sidebar_label: delete
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# delete - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `delete` method. This belongs to the Pricing Module.
|
||||
|
||||
This method deletes price sets by their IDs.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function removePriceSetRule (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.delete(priceSetIds)
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"ids","type":"`string`[]","description":"The IDs of the price sets to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves when the price sets are successfully deleted.","children":[]}]} />
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteCurrencies
|
||||
sidebar_label: deleteCurrencies
|
||||
---
|
||||
|
||||
# deleteCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the deleteCurrencies method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete currencies based on their currency code.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `currencyCodes`: An array of strings, each being a code of a currency to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves once the currencies are deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteCurrencies(["USD"])
|
||||
|
||||
}
|
||||
```
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteCurrencies
|
||||
sidebar_label: deleteCurrencies
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# deleteCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `deleteCurrencies` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete currencies based on their currency code.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteCurrencies(["USD"])
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"currencyCodes","type":"`string`[]","description":"Currency codes of the currencies to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves once the currencies are deleted.","children":[]}]} />
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteMoneyAmounts
|
||||
sidebar_label: deleteMoneyAmounts
|
||||
---
|
||||
|
||||
# deleteMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the deleteMoneyAmounts method. This belongs to the Pricing Module.
|
||||
|
||||
This method deletes money amounts by their IDs.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `ids`: An array of strings, each being the ID of a money amount to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves when the money amounts are successfully deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteMoneyAmounts(
|
||||
moneyAmountIds
|
||||
)
|
||||
}
|
||||
```
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteMoneyAmounts
|
||||
sidebar_label: deleteMoneyAmounts
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# deleteMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `deleteMoneyAmounts` method. This belongs to the Pricing Module.
|
||||
|
||||
This method deletes money amounts by their IDs.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteMoneyAmounts(
|
||||
moneyAmountIds
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"ids","type":"`string`[]","description":"The IDs of the money amounts to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves when the money amounts are successfully deleted.","children":[]}]} />
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deletePriceRules
|
||||
sidebar_label: deletePriceRules
|
||||
---
|
||||
|
||||
# deletePriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the deletePriceRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete price rules based on the specified IDs.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `priceRuleIds`: An array of strings, each being the ID of a price rule to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves once the price rules are deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deletePriceRules (
|
||||
id: string,
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deletePriceRules([id])
|
||||
}
|
||||
```
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deletePriceRules
|
||||
sidebar_label: deletePriceRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# deletePriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `deletePriceRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete price rules based on the specified IDs.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deletePriceRules (
|
||||
id: string,
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deletePriceRules([id])
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"priceRuleIds","type":"`string`[]","description":"The IDs of the price rules to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves once the price rules are deleted.","children":[]}]} />
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deletePriceSetMoneyAmountRules
|
||||
sidebar_label: deletePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# deletePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the deletePriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete price set money amount rules based on the specified IDs.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `ids`: An array of strings, each representing the ID of a price set money amount rule to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves once the price set money amount rules are deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deletePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deletePriceSetMoneyAmountRules([id])
|
||||
}
|
||||
```
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deletePriceSetMoneyAmountRules
|
||||
sidebar_label: deletePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# deletePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `deletePriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete price set money amount rules based on the specified IDs.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deletePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deletePriceSetMoneyAmountRules([id])
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"ids","type":"`string`[]","description":"The IDs of the price set money amount rules to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves once the price set money amount rules are deleted.","children":[]}]} />
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteRuleTypes
|
||||
sidebar_label: deleteRuleTypes
|
||||
---
|
||||
|
||||
# deleteRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the deleteRuleTypes method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete rule types based on the provided IDs.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `ruleTypeIds`: An array of strings, each being the ID of a rule type to delete.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves once the rule types are deleted.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteRuleTypes([ruleTypeId])
|
||||
}
|
||||
```
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/deleteRuleTypes
|
||||
sidebar_label: deleteRuleTypes
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# deleteRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `deleteRuleTypes` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to delete rule types based on the provided IDs.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function deleteRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.deleteRuleTypes([ruleTypeId])
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"ruleTypeIds","type":"`string`[]","description":"The IDs of the rule types to delete.","optional":false,"defaultValue":"","children":[]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves once the rule types are deleted.","children":[]}]} />
|
||||
-172
@@ -1,172 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/list
|
||||
sidebar_label: list
|
||||
---
|
||||
|
||||
# list - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the list method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price sets based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceSetProps](../../interfaces/FilterablePriceSetProps.md) that is used to filter the retrieved price lists. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter price sets.
|
||||
- `money_amounts`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the price sets by their associated money amounts. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter money amounts.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price sets using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price sets:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
money_amounts: {
|
||||
id: moneyAmountIds
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/list
|
||||
sidebar_label: list
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# list - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `list` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price sets based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price sets using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price sets:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSets = await pricingService.list(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
money_amounts: {
|
||||
id: moneyAmountIds
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)","description":"The filters to apply on the retrieved price lists.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter price sets by.","optional":true,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"Filters to apply on a price set's associated money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","description":"The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","Line truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of price sets.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCount
|
||||
sidebar_label: listAndCount
|
||||
---
|
||||
|
||||
# listAndCount - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCount method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceSetProps](../../interfaces/FilterablePriceSetProps.md) that is used to filter the retrieved price lists. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter price sets.
|
||||
- `money_amounts`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the price sets by their associated money amounts. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter money amounts.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array having two items, the first item is an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md),
|
||||
and the second item is a number indicating the total count.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of prices sets using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price sets:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
money_amounts: {
|
||||
id: moneyAmountIds
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCount
|
||||
sidebar_label: listAndCount
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCount - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCount` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of prices sets using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price sets:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSets, count] = await pricingService.listAndCount(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: priceSetIds
|
||||
},
|
||||
{
|
||||
money_amounts: {
|
||||
id: moneyAmountIds
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["money_amounts"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price sets or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)","description":"The filters to apply on the retrieved price lists.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter price sets by.","optional":true,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"Filters to apply on a price set's associated money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","description":"The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","Line truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of price sets along with their total count.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountCurrencies
|
||||
sidebar_label: listAndCountCurrencies
|
||||
---
|
||||
|
||||
# listAndCountCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCountCurrencies method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableCurrencyProps](../../interfaces/FilterableCurrencyProps.md) that is used to filter the retrieved currencies. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `code`: (optional) an array of strings, each being a currency code to filter the currencies.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array having two items, the first item is an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md),
|
||||
and the second item is a number indicating the total count.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CurrencyDTO
|
||||
</summary>
|
||||
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of currencies using their codes:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountCurrencies
|
||||
sidebar_label: listAndCountCurrencies
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCountCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCountCurrencies` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of currencies using their codes:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [currencies, count] = await pricingService.listAndCountCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)","description":"The filters to apply on the retrieved currencies.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","description":"The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of currencies along with the total count.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-160
@@ -1,160 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountMoneyAmounts
|
||||
sidebar_label: listAndCountMoneyAmounts
|
||||
---
|
||||
|
||||
# listAndCountMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCountMoneyAmounts method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the retrieved money amounts. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter money amounts.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array having two items, the first item is an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md),
|
||||
and the second item is a number indicating the total count.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
MoneyAmountDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
currency_code: currencyCode
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountMoneyAmounts
|
||||
sidebar_label: listAndCountMoneyAmounts
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCountMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCountMoneyAmounts` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
currency_code: currencyCode
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"The filters to apply on the retrieved money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","description":"The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of money amounts along with their total count.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountPriceRules
|
||||
sidebar_label: listAndCountPriceRules
|
||||
---
|
||||
|
||||
# listAndCountPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCountPriceRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceRuleProps](../../interfaces/FilterablePriceRuleProps.md) that is used to filter the retrieved price rules. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each indicating an ID to filter price rules.
|
||||
- `name`: (optional) An array of strings, each indicating a name to filter price rules.
|
||||
- `price_set_id`: (optional) An array of strings, each indicating a price set ID to filter price rules.
|
||||
- `rule_type_id`: (optional) An array of strings, each indicating a rule type ID to filter rule types.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceRuleDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountPriceRules
|
||||
sidebar_label: listAndCountPriceRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCountPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCountPriceRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceRules, count] = await pricingService.listAndCountPriceRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)","description":"The filters to apply on the retrieved price rules.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`[]","description":"The IDs to filter the price rule's associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price rule's associated rule type.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of price rules along with their total count.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-163
@@ -1,163 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountPriceSetMoneyAmountRules
|
||||
sidebar_label: listAndCountPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# listAndCountPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCountPriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price set money amount rules along with the total count of
|
||||
available price set money amount rules satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceSetMoneyAmountRulesProps](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.md) that is used to filter the retrieved price set money amount rules. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each string indicating an ID to filter the price set money amount rules.
|
||||
- `price_set_money_amount_id`: (optional) an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules.
|
||||
- `rule_type_id`: (optional) An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules.
|
||||
- `value`: (optional) an array of strings, each string indicating a value to filter the price set money amount rules.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array having two items, the first item is an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md),
|
||||
and the second item is a number indicating the total count.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetMoneyAmountRulesDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount.
|
||||
- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties:
|
||||
- `id`: a string indicating the ID of a price set money amount.
|
||||
- `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set.
|
||||
- `title`: (optional) a string indicating the title of the price set money amount.
|
||||
- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `value`: a string indicating the value of the price set money amount rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price set money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price set money amount rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
rule_type_id: ruleTypeId
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountPriceSetMoneyAmountRules
|
||||
sidebar_label: listAndCountPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCountPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCountPriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price set money amount rules along with the total count of
|
||||
available price set money amount rules satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price set money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price set money amount rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
rule_type_id: ruleTypeId
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)","description":"The filters to apply on the retrieved price set money amount rules.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The ID to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`[]","description":"The value to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","description":"The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is aLine truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of price set money amount rules and their total count.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountRuleTypes
|
||||
sidebar_label: listAndCountRuleTypes
|
||||
---
|
||||
|
||||
# listAndCountRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listAndCountRuleTypes method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableRuleTypeProps](../../interfaces/FilterableRuleTypeProps.md) that is used to filter the retrieved rule types. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) an array of strings, each being an ID to filter rule types.
|
||||
- `name`: (optional) an array of strings, each being a name to filter rule types.
|
||||
- `rule_attribute`: (optional) an array of strings, each being a rule attribute to filter rule types.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array having two items, the first item is an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md),
|
||||
and the second item is a number indicating the total count.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
RuleTypeDTO
|
||||
</summary>
|
||||
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of rule types using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
$and: [
|
||||
{
|
||||
id: ruleTypeId
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listAndCountRuleTypes
|
||||
sidebar_label: listAndCountRuleTypes
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listAndCountRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listAndCountRuleTypes` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of rule types using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
|
||||
$and: [
|
||||
{
|
||||
id: ruleTypeId
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)","description":"The filters to apply on the retrieved rule types.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`[]","description":"The rule attributes to filter rule types by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","description":"The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[], `number`]\\>","optional":false,"defaultValue":"","description":"The list of rule types along with their total count.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} />
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listCurrencies
|
||||
sidebar_label: listCurrencies
|
||||
---
|
||||
|
||||
# listCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listCurrencies method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of currencies based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableCurrencyProps](../../interfaces/FilterableCurrencyProps.md) that is used to filter the retrieved currencies. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `code`: (optional) an array of strings, each being a currency code to filter the currencies.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CurrencyDTO
|
||||
</summary>
|
||||
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of currencies using their codes:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listCurrencies
|
||||
sidebar_label: listCurrencies
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listCurrencies` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of currencies based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of currencies using their codes:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.listCurrencies(
|
||||
{
|
||||
code: codes
|
||||
},
|
||||
{
|
||||
select: ["symbol_native"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)","description":"The filters to apply on the retrieved currencies.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","description":"The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listMoneyAmounts
|
||||
sidebar_label: listMoneyAmounts
|
||||
---
|
||||
|
||||
# listMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listMoneyAmounts method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of money amounts based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the retrieved money amounts. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts.
|
||||
- `id`: (optional) An array of strings, each being an ID to filter money amounts.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
MoneyAmountDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
currency_code: currencyCode
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listMoneyAmounts
|
||||
sidebar_label: listMoneyAmounts
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listMoneyAmounts` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of money amounts based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of money amounts using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the money amounts:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[]) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.listMoneyAmounts(
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
id: moneyAmountIds
|
||||
},
|
||||
{
|
||||
currency_code: currencyCode
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
relations: ["currency"],
|
||||
skip,
|
||||
take
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"The filtes to apply on the retrieved money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","description":"The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listPriceRules
|
||||
sidebar_label: listPriceRules
|
||||
---
|
||||
|
||||
# listPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listPriceRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price rules based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceRuleProps](../../interfaces/FilterablePriceRuleProps.md) that is used to filter the retrieved price rules. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each indicating an ID to filter price rules.
|
||||
- `name`: (optional) An array of strings, each indicating a name to filter price rules.
|
||||
- `price_set_id`: (optional) An array of strings, each indicating a price set ID to filter price rules.
|
||||
- `rule_type_id`: (optional) An array of strings, each indicating a rule type ID to filter rule types.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceRuleDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listPriceRules
|
||||
sidebar_label: listPriceRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listPriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listPriceRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price rules based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
id: [id],
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.listPriceRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)","description":"The filters to apply on the retrieved price rules.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`[]","description":"The IDs to filter the price rule's associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price rule's associated rule type.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listPriceSetMoneyAmountRules
|
||||
sidebar_label: listPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# listPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listPriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterablePriceSetMoneyAmountRulesProps](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.md) that is used to filter the retrieved price set money amount rules. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) An array of strings, each string indicating an ID to filter the price set money amount rules.
|
||||
- `price_set_money_amount_id`: (optional) an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules.
|
||||
- `rule_type_id`: (optional) An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules.
|
||||
- `value`: (optional) an array of strings, each string indicating a value to filter the price set money amount rules.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetMoneyAmountRulesDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount.
|
||||
- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties:
|
||||
- `id`: a string indicating the ID of a price set money amount.
|
||||
- `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set.
|
||||
- `title`: (optional) a string indicating the title of the price set money amount.
|
||||
- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `value`: a string indicating the value of the price set money amount rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price set money amount rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price set money amount rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
rule_type_id: ruleTypeId
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listPriceSetMoneyAmountRules
|
||||
sidebar_label: listPriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listPriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listPriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of price set money amount rules using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved within the price set money amount rules:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
id: [id]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
|
||||
$and: [
|
||||
{
|
||||
id: ids
|
||||
},
|
||||
{
|
||||
rule_type_id: ruleTypeId
|
||||
}
|
||||
]
|
||||
}, {
|
||||
relations: ["price_set_money_amount"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)","description":"The filters to apply on the retrieved price set money amount rules.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The ID to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`[]","description":"The value to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","description":"The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is aLine truncated
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listRuleTypes
|
||||
sidebar_label: listRuleTypes
|
||||
---
|
||||
|
||||
# listRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the listRuleTypes method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of rule types based on optional filters and configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `filters`: (optional) An object of type [FilterableRuleTypeProps](../../interfaces/FilterableRuleTypeProps.md) that is used to filter the retrieved rule types. It accepts the following properties:
|
||||
- `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
- `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
- `id`: (optional) an array of strings, each being an ID to filter rule types.
|
||||
- `name`: (optional) an array of strings, each being a name to filter rule types.
|
||||
- `rule_attribute`: (optional) an array of strings, each being a rule attribute to filter rule types.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
RuleTypeDTO
|
||||
</summary>
|
||||
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of rule types using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
$and: [
|
||||
{
|
||||
id: ruleTypeId
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/listRuleTypes
|
||||
sidebar_label: listRuleTypes
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# listRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `listRuleTypes` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a paginated list of rule types based on optional filters and configuration.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a list of rule types using their IDs:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved within the rule types:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
id: [
|
||||
ruleTypeId
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.listRuleTypes({
|
||||
$and: [
|
||||
{
|
||||
id: ruleTypeId
|
||||
},
|
||||
{
|
||||
name
|
||||
}
|
||||
]
|
||||
}, {
|
||||
select: ["name"],
|
||||
skip,
|
||||
take
|
||||
})
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"filters","type":"[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)","description":"The filters to apply on the retrieved rule types.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`[]","description":"The rule attributes to filter rule types by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","description":"The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/removeRules
|
||||
sidebar_label: removeRules
|
||||
---
|
||||
|
||||
# removeRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the removeRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method remove rules from a price set.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [RemovePriceSetRulesDTO](../../interfaces/RemovePriceSetRulesDTO.md), each specfiying which rules to remove. Its items accept the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `rules`: An array of strings, each string is the `rule_attribute` of a rule you want to remove.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves when rules are successfully removed.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function removePriceSetRule (priceSetId: string, ruleAttributes: []) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.removeRules([
|
||||
{
|
||||
id: priceSetId,
|
||||
rules: ruleAttributes
|
||||
},
|
||||
])
|
||||
}
|
||||
```
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/removeRules
|
||||
sidebar_label: removeRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# removeRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `removeRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method remove rules from a price set.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function removePriceSetRule (priceSetId: string, ruleAttributes: []) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
await pricingService.removeRules([
|
||||
{
|
||||
id: priceSetId,
|
||||
rules: ruleAttributes
|
||||
},
|
||||
])
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`RemovePriceSetRulesDTO`](../../interfaces/RemovePriceSetRulesDTO.mdx)[]","description":"The rules to remove per price set.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"rules","type":"`string`[]","description":"The rules to remove. Each string is the `rule_attribute` of a rule to remove.","optional":false,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<`void`\\>","optional":false,"defaultValue":"","description":"Resolves when rules are successfully removed.","children":[]}]} />
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieve
|
||||
sidebar_label: retrieve
|
||||
---
|
||||
|
||||
# retrieve - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrieve method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieves a price set by its ID.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `id`: A string indicating the ID of the price set to retrieve.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) which is the retrieved price set.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price set by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.retrieve(
|
||||
priceSetId
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.retrieve(
|
||||
priceSetId,
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieve
|
||||
sidebar_label: retrieve
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrieve - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrieve` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieves a price set by its ID.
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price set by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.retrieve(
|
||||
priceSetId
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSet (priceSetId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSet = await pricingService.retrieve(
|
||||
priceSetId,
|
||||
{
|
||||
relations: ["money_amounts"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the price set or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the price set to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","description":"The configurations determining how the price set is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved price set.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveCurrency
|
||||
sidebar_label: retrieveCurrency
|
||||
---
|
||||
|
||||
# retrieveCurrency - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrieveCurrency method. This belongs to the Pricing Module.
|
||||
|
||||
This method retrieves a currency by its code and and optionally based on the provided configurations.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `code`: A string indicating the code of the currency to retrieve.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currency is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CurrencyDTO
|
||||
</summary>
|
||||
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a currency by its code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrency (code: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currency = await pricingService.retrieveCurrency(
|
||||
code
|
||||
)
|
||||
|
||||
// do something with the currency or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrency (code: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currency = await pricingService.retrieveCurrency(
|
||||
code,
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currency or return it
|
||||
}
|
||||
```
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveCurrency
|
||||
sidebar_label: retrieveCurrency
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrieveCurrency - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrieveCurrency` method. This belongs to the Pricing Module.
|
||||
|
||||
This method retrieves a currency by its code and and optionally based on the provided configurations.
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a currency by its code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrency (code: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currency = await pricingService.retrieveCurrency(
|
||||
code
|
||||
)
|
||||
|
||||
// do something with the currency or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveCurrency (code: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currency = await pricingService.retrieveCurrency(
|
||||
code,
|
||||
{
|
||||
select: ["symbol_native"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the currency or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"code","type":"`string`","description":"The code of the currency to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","description":"The configurations determining how the currency is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved currency.","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveMoneyAmount
|
||||
sidebar_label: retrieveMoneyAmount
|
||||
---
|
||||
|
||||
# retrieveMoneyAmount - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrieveMoneyAmount method. This belongs to the Pricing Module.
|
||||
|
||||
This method retrieves a money amount by its ID.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `id`: The ID of the money amount to retrieve.
|
||||
- `config`: (optional) An object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) used to configure how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) which is the retrieved money amount.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
MoneyAmountDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a money amount by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmount (moneyAmountId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
||||
moneyAmountId,
|
||||
)
|
||||
|
||||
// do something with the money amount or return it
|
||||
}
|
||||
```
|
||||
|
||||
To retrieve relations along with the money amount:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmount (moneyAmountId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
||||
moneyAmountId,
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amount or return it
|
||||
}
|
||||
```
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveMoneyAmount
|
||||
sidebar_label: retrieveMoneyAmount
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrieveMoneyAmount - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrieveMoneyAmount` method. This belongs to the Pricing Module.
|
||||
|
||||
This method retrieves a money amount by its ID.
|
||||
|
||||
## Example
|
||||
|
||||
To retrieve a money amount by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmount (moneyAmountId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
||||
moneyAmountId,
|
||||
)
|
||||
|
||||
// do something with the money amount or return it
|
||||
}
|
||||
```
|
||||
|
||||
To retrieve relations along with the money amount:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveMoneyAmount (moneyAmountId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
||||
moneyAmountId,
|
||||
{
|
||||
relations: ["currency"]
|
||||
}
|
||||
)
|
||||
|
||||
// do something with the money amount or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the money amount to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","description":"The configurations determining how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved money amount.","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The price of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)","description":"The money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this price to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this price to be applied.","optional":true,"defaultValue":"","children":[]}]}]}]} />
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrievePriceRule
|
||||
sidebar_label: retrievePriceRule
|
||||
---
|
||||
|
||||
# retrievePriceRule - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrievePriceRule method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a price rule by its ID.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `id`: The ID of the price rule to retrieve.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceRuleDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price rule by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRule = await pricingService.retrievePriceRule(id)
|
||||
|
||||
// do something with the price rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRule = await pricingService.retrievePriceRule(id, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rule or return it
|
||||
}
|
||||
```
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrievePriceRule
|
||||
sidebar_label: retrievePriceRule
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrievePriceRule - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrievePriceRule` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a price rule by its ID.
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price rule by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRule = await pricingService.retrievePriceRule(id)
|
||||
|
||||
// do something with the price rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRule = await pricingService.retrievePriceRule(id, {
|
||||
relations: ["price_set"]
|
||||
})
|
||||
|
||||
// do something with the price rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the price rule to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved price rule.","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price rule.","optional":false,"defaultValue":"","children":[]},{"name":"price_list_id","type":"`string`","description":"The ID of the associated price list.","optional":false,"defaultValue":"","children":[]},{"name":"price_set","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)","description":"The associated price set. It may only be available if the relation `price_set` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`","description":"The ID of the associated price set.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`","description":"The ID of the associated price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"priority","type":"`number`","description":"The priority of the price rule in comparison to other applicable price rules.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)","description":"The associated rule type. It may only be available if the relation `rule_type` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`","description":"The ID of the associated rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price rule.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrievePriceSetMoneyAmountRules
|
||||
sidebar_label: retrievePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# retrievePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrievePriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to a price set money amount rule by its ID based on the provided configuration.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount rule to retrieve.
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetMoneyAmountRulesDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount.
|
||||
- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties:
|
||||
- `id`: a string indicating the ID of a price set money amount.
|
||||
- `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set.
|
||||
- `title`: (optional) a string indicating the title of the price set money amount.
|
||||
- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `value`: a string indicating the value of the price set money amount rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price set money amount rule by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id)
|
||||
|
||||
// do something with the price set money amount rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id, {
|
||||
relations: ["price_set_money_amount"]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rule or return it
|
||||
}
|
||||
```
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrievePriceSetMoneyAmountRules
|
||||
sidebar_label: retrievePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrievePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrievePriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to a price set money amount rule by its ID based on the provided configuration.
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a price set money amount rule by its ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id)
|
||||
|
||||
// do something with the price set money amount rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify relations that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrievePriceSetMoneyAmountRule (id: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id, {
|
||||
relations: ["price_set_money_amount"]
|
||||
})
|
||||
|
||||
// do something with the price set money amount rule or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the price set money amount rule to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","description":"The configurations determining how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved price set money amount rule.","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount","type":"[`PriceSetMoneyAmountDTO`](../../interfaces/PriceSetMoneyAmountDTO.mdx)","description":"The associated price set money amount. It may only be available if the relation `price_set_money_amount` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)","description":"The associated rule type. It may only be available if the relation `rule_type` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price set money amount rule.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveRuleType
|
||||
sidebar_label: retrieveRuleType
|
||||
---
|
||||
|
||||
# retrieveRuleType - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the retrieveRuleType method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a rule type by its ID and and optionally based on the provided configurations.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `code`:
|
||||
- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties:
|
||||
- `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
|
||||
- `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result.
|
||||
- `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result.
|
||||
- `skip`: (optional) A number indicating the number of records to skip before retrieving the results.
|
||||
- `take`: (optional) A number indicating the number of records to return in the result.
|
||||
- `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md).
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
RuleTypeDTO
|
||||
</summary>
|
||||
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a rule type by its code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleType (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleType = await pricingService.retrieveRuleType(ruleTypeId)
|
||||
|
||||
// do something with the rule type or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleType (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleType = await pricingService.retrieveRuleType(ruleTypeId, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule type or return it
|
||||
}
|
||||
```
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/retrieveRuleType
|
||||
sidebar_label: retrieveRuleType
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# retrieveRuleType - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `retrieveRuleType` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to retrieve a rule type by its ID and and optionally based on the provided configurations.
|
||||
|
||||
## Example
|
||||
|
||||
A simple example that retrieves a rule type by its code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleType (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleType = await pricingService.retrieveRuleType(ruleTypeId)
|
||||
|
||||
// do something with the rule type or return it
|
||||
}
|
||||
```
|
||||
|
||||
To specify attributes that should be retrieved:
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function retrieveRuleType (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleType = await pricingService.retrieveRuleType(ruleTypeId, {
|
||||
select: ["name"]
|
||||
})
|
||||
|
||||
// do something with the rule type or return it
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the rule type to retrieve.","optional":false,"defaultValue":"","children":[]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","description":"The configurations determining how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","optional":false,"defaultValue":"","description":"The retrieved rule type.","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[{"name":"default_priority","type":"`number`","description":"The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The display name of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`","description":"The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateCurrencies
|
||||
sidebar_label: updateCurrencies
|
||||
---
|
||||
|
||||
# updateCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the updateCurrencies method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [UpdateCurrencyDTO](../../interfaces/UpdateCurrencyDTO.md), each object containing data to be updated in a currency. Its items accept the following properties:
|
||||
- `code`: a string indicating the code of the currency to update.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md), each object being an updated currency.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
CurrencyDTO
|
||||
</summary>
|
||||
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.updateCurrencies([
|
||||
{
|
||||
code: "USD",
|
||||
symbol: "$",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateCurrencies
|
||||
sidebar_label: updateCurrencies
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# updateCurrencies - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `updateCurrencies` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateCurrencies () {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const currencies = await pricingService.updateCurrencies([
|
||||
{
|
||||
code: "USD",
|
||||
symbol: "$",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the currencies or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`UpdateCurrencyDTO`](../../interfaces/UpdateCurrencyDTO.mdx)[]","description":"The currencies to update, each having the attributes that should be updated in a currency.","optional":false,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency to update.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of updated currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateMoneyAmounts
|
||||
sidebar_label: updateMoneyAmounts
|
||||
---
|
||||
|
||||
# updateMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the updateMoneyAmounts method. This belongs to the Pricing Module.
|
||||
|
||||
This method updates existing money amounts.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [UpdateMoneyAmountDTO](../../interfaces/UpdateMoneyAmountDTO.md), each holding data to update in a money amount. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this money amount.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of the money amount.
|
||||
- `id`: A string that indicates the ID of the money amount to update.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), each being a updated money amount.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
MoneyAmountDTO
|
||||
</summary>
|
||||
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties:
|
||||
- `code`: a string indicating the code of the currency.
|
||||
- `name`: (optional) a string indicating the name of the currency.
|
||||
- `symbol`: (optional) a string indicating the symbol of the currency.
|
||||
- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateMoneyAmounts (moneyAmountId: string, amount: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.updateMoneyAmounts([
|
||||
{
|
||||
id: moneyAmountId,
|
||||
amount
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateMoneyAmounts
|
||||
sidebar_label: updateMoneyAmounts
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# updateMoneyAmounts - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `updateMoneyAmounts` method. This belongs to the Pricing Module.
|
||||
|
||||
This method updates existing money amounts.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateMoneyAmounts (moneyAmountId: string, amount: number) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const moneyAmounts = await pricingService.updateMoneyAmounts([
|
||||
{
|
||||
id: moneyAmountId,
|
||||
amount
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the money amounts or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`UpdateMoneyAmountDTO`](../../interfaces/UpdateMoneyAmountDTO.mdx)[]","description":"The money amounts to update, each having the attributes that should be updated in a money amount.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The price of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The code of the currency to associate with the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount to update.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of updated money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updatePriceRules
|
||||
sidebar_label: updatePriceRules
|
||||
---
|
||||
|
||||
# updatePriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the updatePriceRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update price rules, each with their provided data.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [UpdatePriceRuleDTO](../../interfaces/UpdatePriceRuleDTO.md), each containing the data to update in a price rule. Its items accept the following properties:
|
||||
- `id`: A string indicating the ID of the price rule to update.
|
||||
- `price_list_id`: (optional) A string indicating the ID of the associated price list.
|
||||
- `price_set_id`: (optional) A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: (optional) A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: (optional) A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type_id`: (optional) A string indicating the ID of the associated rule type.
|
||||
- `value`: (optional) A string indicating the value of the price rule.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md), each being an updated price rule.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceRuleDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price rule.
|
||||
- `is_dynamic`: A boolean indicating whether the price rule is dynamic.
|
||||
- `price_list_id`: A string indicating the ID of the associated price list.
|
||||
- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `price_set_id`: A string indicating the ID of the associated price set.
|
||||
- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount.
|
||||
- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `rule_type_id`: A string indicating the ID of the associated rule type.
|
||||
- `value`: A string indicating the value of the price rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updatePriceRules (
|
||||
id: string,
|
||||
priceSetId: string,
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.updatePriceRules([
|
||||
{
|
||||
id,
|
||||
price_set_id: priceSetId,
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updatePriceRules
|
||||
sidebar_label: updatePriceRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# updatePriceRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `updatePriceRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update price rules, each with their provided data.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updatePriceRules (
|
||||
id: string,
|
||||
priceSetId: string,
|
||||
) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceRules = await pricingService.updatePriceRules([
|
||||
{
|
||||
id,
|
||||
price_set_id: priceSetId,
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`UpdatePriceRuleDTO`](../../interfaces/UpdatePriceRuleDTO.mdx)[]","description":"The price rules to update, each having attributes that should be updated in a price rule.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price rule to update.","optional":false,"defaultValue":"","children":[]},{"name":"price_list_id","type":"`string`","description":"The ID of the associated price list.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`","description":"The ID of the associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`","description":"The ID of the associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"priority","type":"`number`","description":"The priority of the price rule in comparison to other applicable price rules.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`","description":"The ID of the associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price rule.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of updated price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updatePriceSetMoneyAmountRules
|
||||
sidebar_label: updatePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
# updatePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the updatePriceSetMoneyAmountRules method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update price set money amount rules, each with their provided data.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [UpdatePriceSetMoneyAmountRulesDTO](../../interfaces/UpdatePriceSetMoneyAmountRulesDTO.md), each containing the data to update in a price set money amount rule. Its items accept the following properties:
|
||||
- `id`: A string indicating the ID of the price set money amount rule to update.
|
||||
- `price_set_money_amount`: (optional) A string indicating the ID of a price set money amount.
|
||||
- `rule_type`: (optional) A string indicating the ID of a rule type.
|
||||
- `value`: (optional) A string indicating the value of the price set money amount rule.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md), each being the
|
||||
updated price set money amount rule.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
PriceSetMoneyAmountRulesDTO
|
||||
</summary>
|
||||
|
||||
- `id`: A string indicating the ID of the price set money amount.
|
||||
- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties:
|
||||
- `id`: a string indicating the ID of a price set money amount.
|
||||
- `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties:
|
||||
- `amount`: (optional) A number indicating the amount of this price.
|
||||
- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
- `currency_code`: (optional) A string that indicates the currency code of this price.
|
||||
- `id`: A string that indicates the ID of the money amount. A money amount represents a price.
|
||||
- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied.
|
||||
- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied.
|
||||
- `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties:
|
||||
- `id`: A string indicating the ID of the price set.
|
||||
- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set.
|
||||
- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set.
|
||||
- `title`: (optional) a string indicating the title of the price set money amount.
|
||||
- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties:
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `value`: a string indicating the value of the price set money amount rule.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updatePriceSetMoneyAmountRules (id: string, value: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.updatePriceSetMoneyAmountRules([
|
||||
{
|
||||
id,
|
||||
value
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updatePriceSetMoneyAmountRules
|
||||
sidebar_label: updatePriceSetMoneyAmountRules
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# updatePriceSetMoneyAmountRules - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `updatePriceSetMoneyAmountRules` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update price set money amount rules, each with their provided data.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updatePriceSetMoneyAmountRules (id: string, value: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const priceSetMoneyAmountRules = await pricingService.updatePriceSetMoneyAmountRules([
|
||||
{
|
||||
id,
|
||||
value
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the price set money amount rules or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`UpdatePriceSetMoneyAmountRulesDTO`](../../interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx)[]","description":"The price set money amounts to update, each having the attributes to update in a price set money amount.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set money amount rule to update.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount","type":"`string`","description":"The ID of a price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type","type":"`string`","description":"The ID of a rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price set money amount rule.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of updated price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateRuleTypes
|
||||
sidebar_label: updateRuleTypes
|
||||
---
|
||||
|
||||
# updateRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the updateRuleTypes method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update existing rule types with the provided data.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `data`: An array of objects of type [UpdateRuleTypeDTO](../../interfaces/UpdateRuleTypeDTO.md), each object containing data to be updated in a rule type. Its items accept the following properties:
|
||||
- `default_priority`: (optional) A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type to update.
|
||||
- `name`: (optional) A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: (optional) A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties:
|
||||
- `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled.
|
||||
- `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
- `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
- `transactionId`: (optional) a string indicating the ID of the current transaction.
|
||||
- `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
## Returns
|
||||
|
||||
A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), each being an updated rule type.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
RuleTypeDTO
|
||||
</summary>
|
||||
|
||||
- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.
|
||||
- `id`: A string indicating the ID of the rule type.
|
||||
- `name`: A string indicating the display name of the rule type.
|
||||
- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.updateRuleTypes([
|
||||
{
|
||||
id: ruleTypeId,
|
||||
name: "Region",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
badge:
|
||||
variant: orange
|
||||
text: Beta
|
||||
slug: /references/pricing/updateRuleTypes
|
||||
sidebar_label: updateRuleTypes
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# updateRuleTypes - Pricing Module Reference
|
||||
|
||||
This documentation provides a reference to the `updateRuleTypes` method. This belongs to the Pricing Module.
|
||||
|
||||
This method is used to update existing rule types with the provided data.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
initialize as initializePricingModule,
|
||||
} from "@medusajs/pricing"
|
||||
|
||||
async function updateRuleTypes (ruleTypeId: string) {
|
||||
const pricingService = await initializePricingModule()
|
||||
|
||||
const ruleTypes = await pricingService.updateRuleTypes([
|
||||
{
|
||||
id: ruleTypeId,
|
||||
name: "Region",
|
||||
}
|
||||
])
|
||||
|
||||
// do something with the rule types or return them
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"data","type":"[`UpdateRuleTypeDTO`](../../interfaces/UpdateRuleTypeDTO.mdx)[]","description":"The rule types to update, each having the attributes that should be updated in a rule type.","optional":false,"defaultValue":"","children":[{"name":"default_priority","type":"`number`","description":"The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the rule type to update.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The display name of the rule type.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`","description":"The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} />
|
||||
|
||||
## Returns
|
||||
|
||||
<ParameterTypes parameters={[{"name":"Promise","type":"`Promise`<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]\\>","optional":false,"defaultValue":"","description":"The list of updated rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} />
|
||||
@@ -2,55 +2,57 @@
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# Pricing Module Reference Reference
|
||||
|
||||
## Interfaces
|
||||
|
||||
- [AddPricesDTO](interfaces/AddPricesDTO.md)
|
||||
- [AddRulesDTO](interfaces/AddRulesDTO.md)
|
||||
- [BaseFilterable](interfaces/BaseFilterable.md)
|
||||
- [CalculatedPriceSetDTO](interfaces/CalculatedPriceSetDTO.md)
|
||||
- [Context](interfaces/Context.md)
|
||||
- [CreateCurrencyDTO](interfaces/CreateCurrencyDTO.md)
|
||||
- [CreateMoneyAmountDTO](interfaces/CreateMoneyAmountDTO.md)
|
||||
- [CreatePriceRuleDTO](interfaces/CreatePriceRuleDTO.md)
|
||||
- [CreatePriceSetDTO](interfaces/CreatePriceSetDTO.md)
|
||||
- [CreatePriceSetMoneyAmountRulesDTO](interfaces/CreatePriceSetMoneyAmountRulesDTO.md)
|
||||
- [CreatePricesDTO](interfaces/CreatePricesDTO.md)
|
||||
- [CreateRuleTypeDTO](interfaces/CreateRuleTypeDTO.md)
|
||||
- [CurrencyDTO](interfaces/CurrencyDTO.md)
|
||||
- [FilterableCurrencyProps](interfaces/FilterableCurrencyProps.md)
|
||||
- [FilterableMoneyAmountProps](interfaces/FilterableMoneyAmountProps.md)
|
||||
- [FilterablePriceRuleProps](interfaces/FilterablePriceRuleProps.md)
|
||||
- [FilterablePriceSetMoneyAmountRulesProps](interfaces/FilterablePriceSetMoneyAmountRulesProps.md)
|
||||
- [FilterablePriceSetProps](interfaces/FilterablePriceSetProps.md)
|
||||
- [FilterableRuleTypeProps](interfaces/FilterableRuleTypeProps.md)
|
||||
- [FindConfig](interfaces/FindConfig.md)
|
||||
- [IPricingModuleService](interfaces/IPricingModuleService.md)
|
||||
- [JoinerServiceConfig](interfaces/JoinerServiceConfig.md)
|
||||
- [JoinerServiceConfigAlias](interfaces/JoinerServiceConfigAlias.md)
|
||||
- [MoneyAmountDTO](interfaces/MoneyAmountDTO.md)
|
||||
- [PriceRuleDTO](interfaces/PriceRuleDTO.md)
|
||||
- [PriceSetDTO](interfaces/PriceSetDTO.md)
|
||||
- [PriceSetMoneyAmountDTO](interfaces/PriceSetMoneyAmountDTO.md)
|
||||
- [PriceSetMoneyAmountRulesDTO](interfaces/PriceSetMoneyAmountRulesDTO.md)
|
||||
- [PricingContext](interfaces/PricingContext.md)
|
||||
- [PricingFilters](interfaces/PricingFilters.md)
|
||||
- [RemovePriceSetRulesDTO](interfaces/RemovePriceSetRulesDTO.md)
|
||||
- [RuleTypeDTO](interfaces/RuleTypeDTO.md)
|
||||
- [UpdateCurrencyDTO](interfaces/UpdateCurrencyDTO.md)
|
||||
- [UpdateMoneyAmountDTO](interfaces/UpdateMoneyAmountDTO.md)
|
||||
- [UpdatePriceRuleDTO](interfaces/UpdatePriceRuleDTO.md)
|
||||
- [UpdatePriceSetDTO](interfaces/UpdatePriceSetDTO.md)
|
||||
- [UpdatePriceSetMoneyAmountRulesDTO](interfaces/UpdatePriceSetMoneyAmountRulesDTO.md)
|
||||
- [UpdateRuleTypeDTO](interfaces/UpdateRuleTypeDTO.md)
|
||||
- [AddPricesDTO](interfaces/AddPricesDTO.mdx)
|
||||
- [AddRulesDTO](interfaces/AddRulesDTO.mdx)
|
||||
- [BaseFilterable](interfaces/BaseFilterable.mdx)
|
||||
- [CalculatedPriceSetDTO](interfaces/CalculatedPriceSetDTO.mdx)
|
||||
- [Context](interfaces/Context.mdx)
|
||||
- [CreateCurrencyDTO](interfaces/CreateCurrencyDTO.mdx)
|
||||
- [CreateMoneyAmountDTO](interfaces/CreateMoneyAmountDTO.mdx)
|
||||
- [CreatePriceRuleDTO](interfaces/CreatePriceRuleDTO.mdx)
|
||||
- [CreatePriceSetDTO](interfaces/CreatePriceSetDTO.mdx)
|
||||
- [CreatePriceSetMoneyAmountRulesDTO](interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx)
|
||||
- [CreatePricesDTO](interfaces/CreatePricesDTO.mdx)
|
||||
- [CreateRuleTypeDTO](interfaces/CreateRuleTypeDTO.mdx)
|
||||
- [CurrencyDTO](interfaces/CurrencyDTO.mdx)
|
||||
- [FilterableCurrencyProps](interfaces/FilterableCurrencyProps.mdx)
|
||||
- [FilterableMoneyAmountProps](interfaces/FilterableMoneyAmountProps.mdx)
|
||||
- [FilterablePriceRuleProps](interfaces/FilterablePriceRuleProps.mdx)
|
||||
- [FilterablePriceSetMoneyAmountRulesProps](interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)
|
||||
- [FilterablePriceSetProps](interfaces/FilterablePriceSetProps.mdx)
|
||||
- [FilterableRuleTypeProps](interfaces/FilterableRuleTypeProps.mdx)
|
||||
- [FindConfig](interfaces/FindConfig.mdx)
|
||||
- [IPricingModuleService](interfaces/IPricingModuleService.mdx)
|
||||
- [JoinerServiceConfig](interfaces/JoinerServiceConfig.mdx)
|
||||
- [JoinerServiceConfigAlias](interfaces/JoinerServiceConfigAlias.mdx)
|
||||
- [MoneyAmountDTO](interfaces/MoneyAmountDTO.mdx)
|
||||
- [PriceRuleDTO](interfaces/PriceRuleDTO.mdx)
|
||||
- [PriceSetDTO](interfaces/PriceSetDTO.mdx)
|
||||
- [PriceSetMoneyAmountDTO](interfaces/PriceSetMoneyAmountDTO.mdx)
|
||||
- [PriceSetMoneyAmountRulesDTO](interfaces/PriceSetMoneyAmountRulesDTO.mdx)
|
||||
- [PricingContext](interfaces/PricingContext.mdx)
|
||||
- [PricingFilters](interfaces/PricingFilters.mdx)
|
||||
- [RemovePriceSetRulesDTO](interfaces/RemovePriceSetRulesDTO.mdx)
|
||||
- [RuleTypeDTO](interfaces/RuleTypeDTO.mdx)
|
||||
- [UpdateCurrencyDTO](interfaces/UpdateCurrencyDTO.mdx)
|
||||
- [UpdateMoneyAmountDTO](interfaces/UpdateMoneyAmountDTO.mdx)
|
||||
- [UpdatePriceRuleDTO](interfaces/UpdatePriceRuleDTO.mdx)
|
||||
- [UpdatePriceSetDTO](interfaces/UpdatePriceSetDTO.mdx)
|
||||
- [UpdatePriceSetMoneyAmountRulesDTO](interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx)
|
||||
- [UpdateRuleTypeDTO](interfaces/UpdateRuleTypeDTO.mdx)
|
||||
|
||||
## Type Aliases
|
||||
|
||||
- [Exclude](types/Exclude.md)
|
||||
- [JoinerRelationship](types/JoinerRelationship.md)
|
||||
- [ModuleJoinerConfig](types/ModuleJoinerConfig.md)
|
||||
- [ModuleJoinerRelationship](types/ModuleJoinerRelationship.md)
|
||||
- [Omit](types/Omit.md)
|
||||
- [Pick](types/Pick.md)
|
||||
- [Record](types/Record.md)
|
||||
- [Exclude](types/Exclude.mdx)
|
||||
- [JoinerRelationship](types/JoinerRelationship.mdx)
|
||||
- [ModuleJoinerConfig](types/ModuleJoinerConfig.mdx)
|
||||
- [ModuleJoinerRelationship](types/ModuleJoinerRelationship.mdx)
|
||||
- [Omit](types/Omit.mdx)
|
||||
- [Pick](types/Pick.mdx)
|
||||
- [Record](types/Record.mdx)
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# AddPricesDTO
|
||||
|
||||
An object used to specify prices to add to a price set.
|
||||
|
||||
## Properties
|
||||
|
||||
### priceSetId
|
||||
|
||||
**priceSetId**: `string`
|
||||
|
||||
A string indicating the ID of the price set to add prices to.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:105](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L105)
|
||||
|
||||
___
|
||||
|
||||
### prices
|
||||
|
||||
**prices**: [`CreatePricesDTO`](CreatePricesDTO.md)[]
|
||||
|
||||
An array of objects of type [CreatePricesDTO](CreatePricesDTO.md), each being a price to add to the price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:106](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L106)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# AddPricesDTO
|
||||
|
||||
The prices to add to a price set.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add prices to.","optional":false,"defaultValue":"","children":[]},{"name":"prices","type":"[`CreatePricesDTO`](CreatePricesDTO.mdx)[]","description":"The prices to add to the price set.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]} />
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# AddRulesDTO
|
||||
|
||||
An object used to specify the rules to add to a price set.
|
||||
|
||||
## Properties
|
||||
|
||||
### priceSetId
|
||||
|
||||
**priceSetId**: `string`
|
||||
|
||||
A string indicating the ID of the price set to add the rules to.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:81](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
### rules
|
||||
|
||||
**rules**: { `attribute`: `string` }[]
|
||||
|
||||
An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:82](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L82)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# AddRulesDTO
|
||||
|
||||
The rules to add to a price set.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"priceSetId","type":"`string`","description":"The ID of the price set to add the rules to.","optional":false,"defaultValue":"","children":[]},{"name":"rules","type":"{ `attribute`: `string` }[]","description":"The rules to add to a price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":false,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,53 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# BaseFilterable
|
||||
|
||||
An object used to allow specifying flexible queries with and/or conditions.
|
||||
|
||||
## Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- **`BaseFilterable`**
|
||||
|
||||
↳ [`FilterablePriceSetProps`](FilterablePriceSetProps.md)
|
||||
|
||||
↳ [`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md)
|
||||
|
||||
↳ [`FilterableCurrencyProps`](FilterableCurrencyProps.md)
|
||||
|
||||
↳ [`FilterableRuleTypeProps`](FilterableRuleTypeProps.md)
|
||||
|
||||
↳ [`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md)
|
||||
|
||||
↳ [`FilterablePriceRuleProps`](FilterablePriceRuleProps.md)
|
||||
|
||||
## Properties
|
||||
|
||||
### $and
|
||||
|
||||
`Optional` **$and**: (`T` \| [`BaseFilterable`](BaseFilterable.md)<`T`\>)[]
|
||||
|
||||
An array of filters to apply on the entity, where each item in the array is joined with an "and" condition.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### $or
|
||||
|
||||
`Optional` **$or**: (`T` \| [`BaseFilterable`](BaseFilterable.md)<`T`\>)[]
|
||||
|
||||
An array of filters to apply on the entity, where each item in the array is joined with an "or" condition.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15)
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# BaseFilterable
|
||||
|
||||
An object used to allow specifying flexible queries with and/or conditions.
|
||||
|
||||
## Type parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"T","type":"`object`","description":"","optional":false,"defaultValue":"","children":[]}]} />
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"$and","type":"(`T` \\| [`BaseFilterable`](BaseFilterable.mdx)<`T`\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"(`T` \\| [`BaseFilterable`](BaseFilterable.mdx)<`T`\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CalculatedPriceSetDTO
|
||||
|
||||
An object that holds the details of a calculated price set.
|
||||
|
||||
## Properties
|
||||
|
||||
### amount
|
||||
|
||||
**amount**: ``null`` \| `number`
|
||||
|
||||
a number indicating the calculated amount. It can possibly be `null` if there's no price set up for the provided context.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:66](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### currency\_code
|
||||
|
||||
**currency\_code**: ``null`` \| `string`
|
||||
|
||||
a string indicating the currency code of the calculated price. It can possibly be `null`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:67](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### id
|
||||
|
||||
**id**: `string`
|
||||
|
||||
a string indicating the ID of the price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:65](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### max\_quantity
|
||||
|
||||
**max\_quantity**: ``null`` \| `number`
|
||||
|
||||
a number indicaitng the maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:69](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### min\_quantity
|
||||
|
||||
**min\_quantity**: ``null`` \| `number`
|
||||
|
||||
a number indicaitng the minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:68](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L68)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CalculatedPriceSetDTO
|
||||
|
||||
A calculated price set's data.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"amount","type":"``null`` \\| `number`","description":"The calculated amount. It can possibly be `null` if there's no price set up for the provided context.","optional":false,"defaultValue":"","children":[]},{"name":"currency_code","type":"``null`` \\| `string`","description":"The currency code of the calculated price. It can possibly be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"``null`` \\| `number`","description":"The maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"min_quantity","type":"``null`` \\| `number`","description":"The minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,75 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# Context
|
||||
|
||||
The interface tag is used to ensure that the type is documented similar to interfaces.
|
||||
|
||||
A shared context object that is used to share resources between the application and the module.
|
||||
|
||||
## Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `TManager` | `unknown` |
|
||||
|
||||
## Properties
|
||||
|
||||
### enableNestedTransactions
|
||||
|
||||
`Optional` **enableNestedTransactions**: `boolean`
|
||||
|
||||
a boolean value indicating whether nested transactions are enabled.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/shared-context.ts:24](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### isolationLevel
|
||||
|
||||
`Optional` **isolationLevel**: `string`
|
||||
|
||||
A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/shared-context.ts:23](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L23)
|
||||
|
||||
___
|
||||
|
||||
### manager
|
||||
|
||||
`Optional` **manager**: `TManager`
|
||||
|
||||
An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/shared-context.ts:22](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### transactionId
|
||||
|
||||
`Optional` **transactionId**: `string`
|
||||
|
||||
a string indicating the ID of the current transaction.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/shared-context.ts:25](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager
|
||||
|
||||
`Optional` **transactionManager**: `TManager`
|
||||
|
||||
An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/shared-context.ts:21](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L21)
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# Context
|
||||
|
||||
The interface tag is used to ensure that the type is documented similar to interfaces.
|
||||
|
||||
A shared context object that is used to share resources between the application and the module.
|
||||
|
||||
## Type parameters
|
||||
|
||||
<ParameterTypes parameters={[{"name":"TManager","type":"`object`","description":"","optional":false,"defaultValue":"","children":[]}]} />
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,56 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreateCurrencyDTO
|
||||
|
||||
An object that holds data to create a currency.
|
||||
|
||||
## Properties
|
||||
|
||||
### code
|
||||
|
||||
**code**: `string`
|
||||
|
||||
a string indicating the code of the currency.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/currency.ts:35](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### name
|
||||
|
||||
**name**: `string`
|
||||
|
||||
a string indicating the name of the currency.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/currency.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### symbol
|
||||
|
||||
**symbol**: `string`
|
||||
|
||||
a string indicating the symbol of the currency.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/currency.ts:36](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### symbol\_native
|
||||
|
||||
**symbol\_native**: `string`
|
||||
|
||||
a string indicating the symbol of the currecy in its native form.
|
||||
This is typically the symbol used when displaying a price.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/currency.ts:37](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L37)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CreateCurrencyDTO
|
||||
|
||||
A currency to create.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,87 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreateMoneyAmountDTO
|
||||
|
||||
*
|
||||
|
||||
An object that holds data to create a money amount.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- **`CreateMoneyAmountDTO`**
|
||||
|
||||
↳ [`CreatePricesDTO`](CreatePricesDTO.md)
|
||||
|
||||
## Properties
|
||||
|
||||
### amount
|
||||
|
||||
`Optional` **amount**: `number`
|
||||
|
||||
A number indicating the amount of this money amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:41](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### currency
|
||||
|
||||
`Optional` **currency**: [`CreateCurrencyDTO`](CreateCurrencyDTO.md)
|
||||
|
||||
An object of type [CurrencyDTO](CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:40](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### currency\_code
|
||||
|
||||
**currency\_code**: `string`
|
||||
|
||||
A string that indicates the currency code of this money amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:39](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### id
|
||||
|
||||
`Optional` **id**: `string`
|
||||
|
||||
A string that indicates the ID of the money amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### max\_quantity
|
||||
|
||||
`Optional` **max\_quantity**: `number`
|
||||
|
||||
A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:43](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### min\_quantity
|
||||
|
||||
`Optional` **min\_quantity**: `number`
|
||||
|
||||
A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:42](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L42)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CreateMoneyAmountDTO
|
||||
|
||||
The money amount to create.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,103 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreatePriceRuleDTO
|
||||
|
||||
An object used to specify the necessary data to create a price rule.
|
||||
|
||||
## Properties
|
||||
|
||||
### id
|
||||
|
||||
**id**: `string`
|
||||
|
||||
A string indicating the ID of the price rule.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### is\_dynamic
|
||||
|
||||
`Optional` **is\_dynamic**: `boolean`
|
||||
|
||||
A boolean indicating whether the price rule is dynamic.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:53](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### price\_list\_id
|
||||
|
||||
**price\_list\_id**: `string`
|
||||
|
||||
A string indicating the ID of the associated price list.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:57](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### price\_set\_id
|
||||
|
||||
**price\_set\_id**: `string`
|
||||
|
||||
A string indicating the ID of the associated price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:51](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L51)
|
||||
|
||||
___
|
||||
|
||||
### price\_set\_money\_amount\_id
|
||||
|
||||
**price\_set\_money\_amount\_id**: `string`
|
||||
|
||||
A string indicating the ID of the associated price set money amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:56](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### priority
|
||||
|
||||
`Optional` **priority**: `number`
|
||||
|
||||
A number indicating the priority of the price rule in comparison to other applicable price rules.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:55](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### rule\_type\_id
|
||||
|
||||
**rule\_type\_id**: `string`
|
||||
|
||||
A string indicating the ID of the associated rule type.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:52](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### value
|
||||
|
||||
**value**: `string`
|
||||
|
||||
A string indicating the value of the price rule.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-rule.ts:54](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L54)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CreatePriceRuleDTO
|
||||
|
||||
A price rule to create.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"The ID of the price rule.","optional":false,"defaultValue":"","children":[]},{"name":"price_list_id","type":"`string`","description":"The ID of the associated price list.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`","description":"The ID of the associated price set.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`","description":"The ID of the associated price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"priority","type":"`number`","description":"The priority of the price rule in comparison to other applicable price rules.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`","description":"The ID of the associated rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price rule.","optional":false,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreatePriceSetDTO
|
||||
|
||||
An object of expected properties when creating a price set.
|
||||
|
||||
## Properties
|
||||
|
||||
### prices
|
||||
|
||||
`Optional` **prices**: [`CreatePricesDTO`](CreatePricesDTO.md)[]
|
||||
|
||||
An array of objects of type [CreatePricesDTO](CreatePricesDTO.md), each being a price to associate with the price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:134](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### rules
|
||||
|
||||
`Optional` **rules**: { `rule_attribute`: `string` }[]
|
||||
|
||||
An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type.
|
||||
This property is used to specify the rule types associated with the price set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:133](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L133)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CreatePriceSetDTO
|
||||
|
||||
A price set to create.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"prices","type":"[`CreatePricesDTO`](CreatePricesDTO.mdx)[]","description":"The prices to create and add to this price set.","optional":true,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The amount of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CreateCurrencyDTO`](CreateCurrencyDTO.mdx)","description":"The currency of this money amount.","optional":true,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","children":[]}]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":true,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this money amount to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"rules","type":"Record<`string`, `string`\\>","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]} />
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreatePriceSetMoneyAmountRulesDTO
|
||||
|
||||
An object used to create a price set money amount rule, which represents an association between a price set money amount and a rule type.
|
||||
|
||||
## Properties
|
||||
|
||||
### price\_set\_money\_amount
|
||||
|
||||
**price\_set\_money\_amount**: `string`
|
||||
|
||||
A string indicating the ID of a price set money amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set-money-amount-rules.ts:32](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### rule\_type
|
||||
|
||||
**rule\_type**: `string`
|
||||
|
||||
A string indicating the ID of a rule type.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set-money-amount-rules.ts:33](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### value
|
||||
|
||||
**value**: `string`
|
||||
|
||||
A string indicating the value of the price set money amount rule.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set-money-amount-rules.ts:34](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L34)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
import ParameterTypes from "@site/src/components/ParameterTypes"
|
||||
|
||||
# CreatePriceSetMoneyAmountRulesDTO
|
||||
|
||||
The price set money amount rule to create.
|
||||
|
||||
## Properties
|
||||
|
||||
<ParameterTypes parameters={[{"name":"price_set_money_amount","type":"`string`","description":"The ID of a price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"`string`","description":"The ID of a rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price set money amount rule.","optional":false,"defaultValue":"","children":[]}]} />
|
||||
@@ -1,121 +0,0 @@
|
||||
---
|
||||
displayed_sidebar: pricingReference
|
||||
---
|
||||
|
||||
# CreatePricesDTO
|
||||
|
||||
An object used to pass prices data when creating a price set.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- [`CreateMoneyAmountDTO`](CreateMoneyAmountDTO.md)
|
||||
|
||||
↳ **`CreatePricesDTO`**
|
||||
|
||||
## Properties
|
||||
|
||||
### amount
|
||||
|
||||
`Optional` **amount**: `number`
|
||||
|
||||
A number indicating the amount of this money amount.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[amount](CreateMoneyAmountDTO.md#amount)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:41](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### currency
|
||||
|
||||
`Optional` **currency**: [`CreateCurrencyDTO`](CreateCurrencyDTO.md)
|
||||
|
||||
An object of type [CurrencyDTO](CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[currency](CreateMoneyAmountDTO.md#currency)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:40](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### currency\_code
|
||||
|
||||
**currency\_code**: `string`
|
||||
|
||||
A string that indicates the currency code of this money amount.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[currency_code](CreateMoneyAmountDTO.md#currency_code)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:39](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### id
|
||||
|
||||
`Optional` **id**: `string`
|
||||
|
||||
A string that indicates the ID of the money amount.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[id](CreateMoneyAmountDTO.md#id)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### max\_quantity
|
||||
|
||||
`Optional` **max\_quantity**: `number`
|
||||
|
||||
A number that indicates the maximum quantity required to be purchased for this money amount to be applied.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[max_quantity](CreateMoneyAmountDTO.md#max_quantity)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:43](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### min\_quantity
|
||||
|
||||
`Optional` **min\_quantity**: `number`
|
||||
|
||||
A number that indicates the minimum quantity required to be purchased for this money amount to be applied.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[min_quantity](CreateMoneyAmountDTO.md#min_quantity)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/money-amount.ts:42](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### rules
|
||||
|
||||
**rules**: [`Record`](../types/Record.md)<`string`, `string`\>
|
||||
|
||||
An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/types/src/pricing/common/price-set.ts:93](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L93)
|
||||
Loaded 100 of 218 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user