docs: generate pricing module reference (#5349)

* docs: generate pricing module reference

* added notes about new configurations
This commit is contained in:
Shahed Nasser
2023-10-11 14:08:19 +03:00
committed by GitHub
parent 9c1c19f409
commit f0af8ecc89
110 changed files with 7170 additions and 146 deletions

View File

@@ -0,0 +1,258 @@
---
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
}
```

View File

@@ -0,0 +1,144 @@
---
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
}
```

View File

@@ -0,0 +1,66 @@
---
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
}
```

View File

@@ -0,0 +1,273 @@
---
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
}
```

View File

@@ -0,0 +1,67 @@
---
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
}
```

View File

@@ -0,0 +1,83 @@
---
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
}
```

View File

@@ -0,0 +1,103 @@
---
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
}
```

View File

@@ -0,0 +1,84 @@
---
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
}
```

View File

@@ -0,0 +1,65 @@
---
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
}
```

View File

@@ -0,0 +1,42 @@
---
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)
}
```

View File

@@ -0,0 +1,43 @@
---
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"])
}
```

View File

@@ -0,0 +1,44 @@
---
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
)
}
```

View File

@@ -0,0 +1,44 @@
---
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])
}
```

View File

@@ -0,0 +1,42 @@
---
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])
}
```

View File

@@ -0,0 +1,42 @@
---
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])
}
```

View File

@@ -0,0 +1,172 @@
---
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
}
```

View File

@@ -0,0 +1,173 @@
---
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
}
```

View File

@@ -0,0 +1,121 @@
---
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
}
```

View File

@@ -0,0 +1,160 @@
---
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
}
```

View File

@@ -0,0 +1,167 @@
---
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
}
```

View File

@@ -0,0 +1,163 @@
---
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
}
```

View File

@@ -0,0 +1,150 @@
---
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
}
```

View File

@@ -0,0 +1,120 @@
---
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
}
```

View File

@@ -0,0 +1,159 @@
---
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
}
```

View File

@@ -0,0 +1,167 @@
---
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
}
```

View File

@@ -0,0 +1,161 @@
---
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
}
```

View File

@@ -0,0 +1,149 @@
---
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
}
```

View File

@@ -0,0 +1,49 @@
---
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
},
])
}
```

View File

@@ -0,0 +1,101 @@
---
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
}
```

View File

@@ -0,0 +1,88 @@
---
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
}
```

View File

@@ -0,0 +1,98 @@
---
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
}
```

View File

@@ -0,0 +1,106 @@
---
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
}
```

View File

@@ -0,0 +1,100 @@
---
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
}
```

View File

@@ -0,0 +1,83 @@
---
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
}
```

View File

@@ -0,0 +1,65 @@
---
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
}
```

View File

@@ -0,0 +1,72 @@
---
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
}
```

View File

@@ -0,0 +1,94 @@
---
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
}
```

View File

@@ -0,0 +1,83 @@
---
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
}
```

View File

@@ -0,0 +1,65 @@
---
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
}
```