Skip to main content
Skip to main content

IPricingModuleService

Methods

addPriceListPrices

**addPriceListPrices**(data, sharedContext?): Promise<[PriceListDTO](/references/services/interfaces/PriceListDTO)[]>

This method is used to add prices to price lists.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function addPriceListPrices (items: {
priceListId: string,
prices: {
currency_code: string,
amount: number,
price_set_id: string
}[]
}[]) {
const pricingService = await initializePricingModule()

const priceLists = await pricingService.addPriceListPrices(items)

// do something with the price lists or return them
}

Parameters

dataAddPriceListPricesDTO[]Required
The prices to add for each price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO[]>

PromisePromise<PriceListDTO[]>Required
The updated price lists.

addPrices

**addPrices**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)&#62;

This method adds prices to a price set.

Example

To add a default price to a price set, don't pass it any rules and make sure to pass it the currency_code:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function addPricesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSet = await pricingService.addPrices({
priceSetId,
prices: [
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow"
},
},
{
amount: 400,
currency_code: "EUR",
min_quantity: 0,
max_quantity: 4,
rules: {
region_id: "PL"
},
},
{
amount: 450,
currency_code: "EUR",
rules: {
city: "krakow"
},
}
],
})

// do something with the price set or return it
}

Parameters

dataAddPricesDTORequired
The data defining the price set to add the prices to, along with the prices to add.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO>

PromisePromise<PriceSetDTO>Required
The price set that the prices were added to.

**addPrices**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)[]&#62;

This method adds prices to multiple price sets.

Example

To add a default price to a price set, don't pass it any rules and make sure to pass it the currency_code:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function addPricesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSets = await pricingService.addPrices([{
priceSetId,
prices: [
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow"
},
},
{
amount: 400,
currency_code: "EUR",
min_quantity: 0,
max_quantity: 4,
rules: {
region_id: "PL"
},
},
{
amount: 450,
currency_code: "EUR",
rules: {
city: "krakow"
},
}
],
}])

// do something with the price sets or return them
}

Parameters

dataAddPricesDTO[]Required
The data defining the prices to add per price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO[]>

PromisePromise<PriceSetDTO[]>Required
The list of the price sets that prices were added to.

addRules

**addRules**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)&#62;

This method adds rules to a price set.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function addRulesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSet = await pricingService.addRules({
priceSetId,
rules: [{
attribute: "region_id"
}]
})

// do something with the price set or return it
}

Parameters

dataAddRulesDTORequired
The data defining the price set to add the rules to, along with the rules to add.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO>

PromisePromise<PriceSetDTO>Required
The price set that the rules were added to.

**addRules**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)[]&#62;

This method adds rules to multiple price sets.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function addRulesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSets = await pricingService.addRules([{
priceSetId,
rules: [{
attribute: "region_id"
}]
}])

// do something with the price sets or return them
}

Parameters

dataAddRulesDTO[]Required
The data defining the rules to add per price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO[]>

PromisePromise<PriceSetDTO[]>Required
The list of the price sets that the rules were added to.

calculatePrices

**calculatePrices**(filters, context?, sharedContext?): Promise&#60;[CalculatedPriceSetDTO](/references/services/interfaces/CalculatedPriceSetDTO)&#62;

This method is used to calculate prices based on the provided filters and context.

Example

When you calculate prices, you must at least specify the currency code:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function calculatePrice (priceSetId: string, currencyCode: string) {
const pricingService = await initializePricingModule()

const price = await pricingService.calculatePrices(
{ id: [priceSetId] },
{
context: {
currency_code: currencyCode
}
}
)

// do something with the price or return it
}

To calculate prices for specific minimum and/or maximum quantity:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function calculatePrice (priceSetId: string, currencyCode: string) {
const pricingService = await initializePricingModule()

const price = await pricingService.calculatePrices(
{ id: [priceSetId] },
{
context: {
currency_code: currencyCode,
min_quantity: 4
}
}
)

// do something with the price or return it
}

To calculate prices for custom rule types:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function calculatePrice (priceSetId: string, currencyCode: string) {
const pricingService = await initializePricingModule()

const price = await pricingService.calculatePrices(
{ id: [priceSetId] },
{
context: {
currency_code: currencyCode,
region_id: "US"
}
}
)

// do something with the price or return it
}

Parameters

filtersPricingFiltersRequired
The filters to apply on prices.
The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value will be retrieved.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<CalculatedPriceSetDTO>

PromisePromise<CalculatedPriceSetDTO>Required
The calculated price matching the context and filters provided.

create

**create**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)&#62;

This method is used to create a new price set.

Example

To create a default price set, don't pass any rules. For example:

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:

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function createPriceSet() {
const pricingService = await initializePricingModule()

const priceSet = await pricingService.create({
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
prices: [
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow",
},
},
{
amount: 400,
currency_code: "EUR",
rules: {
region_id: "PL",
},
},
{
amount: 450,
currency_code: "EUR",
rules: {
city: "krakow",
},
},
],
})

// do something with the price set or return it
}

Parameters

dataCreatePriceSetDTORequired
The attributes of the price set to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO>

PromisePromise<PriceSetDTO>Required
The created price set.

**create**(data, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)[]&#62;

This method is used to create multiple price sets.

Example

To create price sets with a default price, don't pass any rules and make sure to pass the currency_code of the price. For example:

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:

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function createPriceSets() {
const pricingService = await initializePricingModule()

const priceSets = await pricingService.create([
{
rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }],
prices: [
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow",
},
},
{
amount: 400,
currency_code: "EUR",
min_quantity: 0,
max_quantity: 4,
rules: {
region_id: "PL",
},
},
{
amount: 450,
currency_code: "EUR",
rules: {
city: "krakow",
},
},
],
},
])

// do something with the price sets or return them
}

Parameters

dataCreatePriceSetDTO[]Required
The price sets to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO[]>

PromisePromise<PriceSetDTO[]>Required
The list of created price sets.

createCurrencies

**createCurrencies**(data, sharedContext?): Promise&#60;[CurrencyDTO](/references/services/interfaces/CurrencyDTO)[]&#62;

This method is used to create new currencies.

Example

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function createCurrencies() {
const pricingService = await initializePricingModule()

const currencies = await pricingService.createCurrencies([
{
code: "USD",
symbol: "$",
symbol_native: "$",
name: "US Dollar",
},
])

// do something with the currencies or return them
}

Parameters

dataCreateCurrencyDTO[]Required
The currencies to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<CurrencyDTO[]>

PromisePromise<CurrencyDTO[]>Required
The list of created currencies.

createMoneyAmounts

**createMoneyAmounts**(data, sharedContext?): Promise&#60;[MoneyAmountDTO](/references/services/interfaces/MoneyAmountDTO)[]&#62;

This method creates money amounts.

Example

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function retrieveMoneyAmounts() {
const pricingService = await initializePricingModule()

const moneyAmounts = await pricingService.createMoneyAmounts([
{
amount: 500,
currency_code: "USD",
},
{
amount: 400,
currency_code: "USD",
min_quantity: 0,
max_quantity: 4,
},
])

// do something with the money amounts or return them
}

Parameters

dataCreateMoneyAmountDTO[]Required
The money amounts to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<MoneyAmountDTO[]>

PromisePromise<MoneyAmountDTO[]>Required
The list of created money amounts.

createPriceListRules

**createPriceListRules**(data, sharedContext?): Promise&#60;[PriceListRuleDTO](/references/services/interfaces/PriceListRuleDTO)[]&#62;

This method is used to create price list rules.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function createPriceListRules (items: {
rule_type_id: string
price_list_id: string
}[]) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.createPriceListRules(items)

// do something with the price list rule or return them
}

Parameters

The price list rules to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListRuleDTO[]>

PromisePromise<PriceListRuleDTO[]>Required
The created price list rules.

createPriceLists

**createPriceLists**(data, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)[]&#62;

This method is used to create price lists.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function createPriceList (items: {
title: string
description: string
starts_at?: string
ends_at?: string
}[]) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.createPriceLists(items)

// do something with the price lists or return them
}

Parameters

dataCreatePriceListDTO[]Required
The details of each price list to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO[]>

PromisePromise<PriceListDTO[]>Required
The created price lists.

createPriceRules

**createPriceRules**(data, sharedContext?): Promise&#60;[PriceRuleDTO](/references/services/interfaces/PriceRuleDTO)[]&#62;

This method is used to create new price rules based on the provided data.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function createPriceRules (
id: string,
priceSetId: string,
ruleTypeId: string,
value: string,
priceSetMoneyAmountId: string,
priceListId: string
) {
const pricingService = await initializePricingModule()

const priceRules = await pricingService.createPriceRules([
{
id,
price_set_id: priceSetId,
rule_type_id: ruleTypeId,
value,
price_set_money_amount_id: priceSetMoneyAmountId,
price_list_id: priceListId
}
])

// do something with the price rules or return them
}

Parameters

dataCreatePriceRuleDTO[]Required
The price rules to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceRuleDTO[]>

PromisePromise<PriceRuleDTO[]>Required
The list of created price rules.

createPriceSetMoneyAmountRules

**createPriceSetMoneyAmountRules**(data, sharedContext?): Promise&#60;[PriceSetMoneyAmountRulesDTO](/references/services/interfaces/PriceSetMoneyAmountRulesDTO)[]&#62;

This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and a rule type.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function createPriceSetMoneyAmountRules (priceSetMoneyAmountId: string, ruleTypeId: string, value: string) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmountRules = await pricingService.createPriceSetMoneyAmountRules([
{
price_set_money_amount: priceSetMoneyAmountId,
rule_type: ruleTypeId,
value
}
])

// do something with the price set money amount rules or return them
}

Parameters

The price set money amount rules to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetMoneyAmountRulesDTO[]>

PromisePromise<PriceSetMoneyAmountRulesDTO[]>Required
The list of created price set money amount rules.

createRuleTypes

**createRuleTypes**(data, sharedContext?): Promise&#60;[RuleTypeDTO](/references/services/interfaces/RuleTypeDTO)[]&#62;

This method is used to create new rule types.

Example

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function createRuleTypes() {
const pricingService = await initializePricingModule()

const ruleTypes = await pricingService.createRuleTypes([
{
name: "Region",
rule_attribute: "region_id",
},
])

// do something with the rule types or return them
}

Parameters

dataCreateRuleTypeDTO[]Required
The rule types to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<RuleTypeDTO[]>

PromisePromise<RuleTypeDTO[]>Required
The list of created rule types.

delete

**delete**(ids, sharedContext?): Promise&#60;void&#62;

This method deletes price sets by their IDs.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function removePriceSetRule (priceSetIds: string[]) {
const pricingService = await initializePricingModule()

await pricingService.delete(priceSetIds)
}

Parameters

idsstring[]Required
The IDs of the price sets to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the price sets are successfully deleted.

deleteCurrencies

**deleteCurrencies**(currencyCodes, sharedContext?): Promise&#60;void&#62;

This method is used to delete currencies based on their currency code.

Example

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function deleteCurrencies() {
const pricingService = await initializePricingModule()

await pricingService.deleteCurrencies(["USD"])
}

Parameters

currencyCodesstring[]Required
Currency codes of the currencies to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves once the currencies are deleted.

deleteMoneyAmounts

**deleteMoneyAmounts**(ids, sharedContext?): Promise&#60;void&#62;

This method deletes money amounts by their IDs.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deleteMoneyAmounts (moneyAmountIds: string[]) {
const pricingService = await initializePricingModule()

await pricingService.deleteMoneyAmounts(
moneyAmountIds
)
}

Parameters

idsstring[]Required
The IDs of the money amounts to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the money amounts are successfully deleted.

deletePriceListRules

**deletePriceListRules**(priceListRuleIds, sharedContext?): Promise&#60;void&#62;

This method is used to delete price list rules.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deletePriceListRules (priceListRuleIds: string[]) {
const pricingService = await initializePricingModule()

await pricingService.deletePriceListRules(priceListRuleIds)
}

Parameters

priceListRuleIdsstring[]Required
The IDs of the price list rules to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves successfully when the price list rules are deleted.

deletePriceLists

**deletePriceLists**(priceListIds, sharedContext?): Promise&#60;void&#62;

This method is used to delete price lists.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deletePriceLists (ids: string[]) {
const pricingService = await initializePricingModule()

await pricingService.deletePriceLists(ids)
}

Parameters

priceListIdsstring[]Required
The IDs of the price lists to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the price lists are deleted successfully.

deletePriceRules

**deletePriceRules**(priceRuleIds, sharedContext?): Promise&#60;void&#62;

This method is used to delete price rules based on the specified IDs.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deletePriceRules (
id: string,
) {
const pricingService = await initializePricingModule()

await pricingService.deletePriceRules([id])
}

Parameters

priceRuleIdsstring[]Required
The IDs of the price rules to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves once the price rules are deleted.

deletePriceSetMoneyAmountRules

**deletePriceSetMoneyAmountRules**(ids, sharedContext?): Promise&#60;void&#62;

This method is used to delete price set money amount rules based on the specified IDs.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deletePriceSetMoneyAmountRule (id: string) {
const pricingService = await initializePricingModule()

await pricingService.deletePriceSetMoneyAmountRules([id])
}

Parameters

idsstring[]Required
The IDs of the price set money amount rules to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves once the price set money amount rules are deleted.

deleteRuleTypes

**deleteRuleTypes**(ruleTypeIds, sharedContext?): Promise&#60;void&#62;

This method is used to delete rule types based on the provided IDs.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function deleteRuleTypes (ruleTypeId: string) {
const pricingService = await initializePricingModule()

await pricingService.deleteRuleTypes([ruleTypeId])
}

Parameters

ruleTypeIdsstring[]Required
The IDs of the rule types to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves once the rule types are deleted.

list

**list**(filters?, config?, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)[]&#62;

This method is used to retrieve a paginated list of price sets based on optional filters and configuration.

Example

To retrieve a list of price sets using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceSets = await pricingService.list(
{
$and: [
{
id: priceSetIds
},
{
money_amounts: {
id: moneyAmountIds
}
}
]
},
{
relations: ["money_amounts"],
skip,
take
}
)

// do something with the price sets or return them
}

Parameters

The filters to apply on the retrieved price lists.
The configurations determining how the price sets are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO[]>

PromisePromise<PriceSetDTO[]>Required
The list of price sets.

listAndCount

**listAndCount**(filters?, config?, sharedContext?): Promise&#60;[[PriceSetDTO](/references/services/interfaces/PriceSetDTO)[], number]&#62;

This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters.

Example

To retrieve a list of prices sets using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSets, count] = await pricingService.listAndCount(
{
$and: [
{
id: priceSetIds
},
{
money_amounts: {
id: moneyAmountIds
}
}
]
},
{
relations: ["money_amounts"],
skip,
take
}
)

// do something with the price sets or return them
}

Parameters

The filters to apply on the retrieved price lists.
The configurations determining how the price sets are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceSetDTO[], number]>

PromisePromise<[PriceSetDTO[], number]>Required
The list of price sets along with their total count.

listAndCountCurrencies

**listAndCountCurrencies**(filters?, config?, sharedContext?): Promise&#60;[[CurrencyDTO](/references/services/interfaces/CurrencyDTO)[], number]&#62;

This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters.

Example

To retrieve a list of currencies using their codes:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveCurrencies (codes: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [currencies, count] = await pricingService.listAndCountCurrencies(
{
code: codes
},
{
select: ["symbol_native"],
skip,
take
}
)

// do something with the currencies or return them
}

Parameters

The filters to apply on the retrieved currencies.
The configurations determining how the currencies are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a currency.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[CurrencyDTO[], number]>

PromisePromise<[CurrencyDTO[], number]>Required
The list of currencies along with the total count.

listAndCountMoneyAmounts

**listAndCountMoneyAmounts**(filters?, config?, sharedContext?): Promise&#60;[[MoneyAmountDTO](/references/services/interfaces/MoneyAmountDTO)[], number]&#62;

This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters.

Example

To retrieve a list of money amounts using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts(
{
$and: [
{
id: moneyAmountIds
},
{
currency_code: currencyCode
}
]
},
{
relations: ["currency"],
skip,
take
}
)

// do something with the money amounts or return them
}

Parameters

The filters to apply on the retrieved money amounts.
The configurations determining how the money amounts are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[MoneyAmountDTO[], number]>

PromisePromise<[MoneyAmountDTO[], number]>Required
The list of money amounts along with their total count.

listAndCountPriceListRules

**listAndCountPriceListRules**(filters?, config?, sharedContext?): Promise&#60;[[PriceListRuleDTO](/references/services/interfaces/PriceListRuleDTO)[], number]&#62;

This method is used to retrieve a paginated list of price list ruless along with the total count of available price list ruless satisfying the provided filters.

Example

To retrieve a list of price list vs using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listAndCountPriceListRules (priceListRuleIds: string[]) {
const pricingService = await initializePricingModule()

const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
{
id: priceListRuleIds
},
)

// do something with the price list rules or return them
}

To specify relations that should be retrieved within the price list rules:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listAndCountPriceListRules (priceListRuleIds: string[]) {
const pricingService = await initializePricingModule()

const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
{
id: priceListRuleIds
},
{
relations: ["price_list_rule_values"]
}
)

// do something with the price list 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listAndCountPriceListRules (priceListRuleIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
{
id: priceListRuleIds
},
{
relations: ["price_list_rule_values"],
skip,
take
}
)

// do something with the price list 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listAndCountPriceListRules (priceListRuleIds: string[], ruleTypeIDs: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceListRules, count] = await pricingService.listAndCountPriceListRules(
{
$and: [
{
id: priceListRuleIds
},
{
rule_types: ruleTypeIDs
}
]
},
{
relations: ["price_list_rule_values"],
skip,
take
}
)

// do something with the price list rules or return them
}

Parameters

The filters to apply on the retrieved price list rules.
The configurations determining how the price list rules are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceListRuleDTO[], number]>

PromisePromise<[PriceListRuleDTO[], number]>Required
The list of price list rules along with their total count.

listAndCountPriceLists

**listAndCountPriceLists**(filters?, config?, sharedContext?): Promise&#60;[[PriceListDTO](/references/services/interfaces/PriceListDTO)[], number]&#62;

This method is used to retrieve a paginated list of price lists along with the total count of available price lists satisfying the provided filters.

Example

To retrieve a list of price lists using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceLists (priceListIds: string[]) {
const pricingService = await initializePricingModule()

const [priceLists, count] = await pricingService.listPriceLists(
{
id: priceListIds
},
)

// do something with the price lists or return them
}

To specify relations that should be retrieved within the price lists:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceLists (priceListIds: string[]) {
const pricingService = await initializePricingModule()

const [priceLists, count] = await pricingService.listPriceLists(
{
id: priceListIds
},
{
relations: ["price_set_money_amounts"]
}
)

// do something with the price lists 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceLists (priceListIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceLists, count] = await pricingService.listPriceLists(
{
id: priceListIds
},
{
relations: ["price_set_money_amounts"],
skip,
take
}
)

// do something with the price lists 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceLists (priceListIds: string[], titles: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceLists, count] = await pricingService.listPriceLists(
{
$and: [
{
id: priceListIds
},
{
title: titles
}
]
},
{
relations: ["price_set_money_amounts"],
skip,
take
}
)

// do something with the price lists or return them
}

Parameters

The filters to apply on the retrieved price lists.
The configurations determining how the price lists are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceListDTO[], number]>

PromisePromise<[PriceListDTO[], number]>Required
The list of price lists along with their total count.

listAndCountPriceRules

**listAndCountPriceRules**(filters?, config?, sharedContext?): Promise&#60;[[PriceRuleDTO](/references/services/interfaces/PriceRuleDTO)[], number]&#62;

This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters.

Example

To retrieve a list of price rules using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceRules, count] = await pricingService.listAndCountPriceRules({
$and: [
{
id: ids
},
{
name
}
]
}, {
relations: ["price_set"],
skip,
take
})

// do something with the price rules or return them
}

Parameters

The filters to apply on the retrieved price rules.
The configurations determining how the price rule is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceRuleDTO[], number]>

PromisePromise<[PriceRuleDTO[], number]>Required
The list of price rules along with their total count.

listAndCountPriceSetMoneyAmountRules

**listAndCountPriceSetMoneyAmountRules**(filters?, config?, sharedContext?): Promise&#60;[[PriceSetMoneyAmountRulesDTO](/references/services/interfaces/PriceSetMoneyAmountRulesDTO)[], number]&#62;

This method is used to retrieve a paginated list of price set money amount rules along with the total count of available price set money amount rules satisfying the provided filters.

Example

To retrieve a list of price set money amounts using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
$and: [
{
id: ids
},
{
rule_type_id: ruleTypeId
}
]
}, {
relations: ["price_set_money_amount"],
skip,
take
})

// do something with the price set money amount rules or return them
}

Parameters

The filters to apply on the retrieved price set money amount rules.
The configurations determining how the price set money amount rules are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set money amount rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceSetMoneyAmountRulesDTO[], number]>

PromisePromise<[PriceSetMoneyAmountRulesDTO[], number]>Required
The list of price set money amount rules and their total count.

listAndCountPriceSetMoneyAmounts

**listAndCountPriceSetMoneyAmounts**(filters?, config?, sharedContext?): Promise&#60;[[PriceSetMoneyAmountDTO](/references/services/interfaces/PriceSetMoneyAmountDTO)[], number]&#62;

This method is used to retrieve a paginated list of price set money amounts along with the total count of available price set money amounts satisfying the provided filters.

Example

To retrieve a list of price set money amounts using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
})

// do something with the price set money amounts or return them
}

To specify relations that should be retrieved within the price set money amounts:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"],
})

// do something with the price set 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string, skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (ids: string[], titles: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
$and: [
{
id: ids
},
{
title: titles
}
]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set money amounts or return them
}

Parameters

The filters to apply on the retrieved price set money amounts.
The configurations determining how the price set money amounts are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[PriceSetMoneyAmountDTO[], number]>

PromisePromise<[PriceSetMoneyAmountDTO[], number]>Required
The list of price set money amounts and their total count.

listAndCountRuleTypes

**listAndCountRuleTypes**(filters?, config?, sharedContext?): Promise&#60;[[RuleTypeDTO](/references/services/interfaces/RuleTypeDTO)[], number]&#62;

This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters.

Example

To retrieve a list of rule types using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({
$and: [
{
id: ruleTypeId
},
{
name
}
]
}, {
select: ["name"],
skip,
take
})

// do something with the rule types or return them
}

Parameters

The filters to apply on the retrieved rule types.
The configurations determining how the rule types are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a rule type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[RuleTypeDTO[], number]>

PromisePromise<[RuleTypeDTO[], number]>Required
The list of rule types along with their total count.

listCurrencies

**listCurrencies**(filters?, config?, sharedContext?): Promise&#60;[CurrencyDTO](/references/services/interfaces/CurrencyDTO)[]&#62;

This method is used to retrieve a paginated list of currencies based on optional filters and configuration.

Example

To retrieve a list of currencies using their codes:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveCurrencies (codes: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const currencies = await pricingService.listCurrencies(
{
code: codes
},
{
select: ["symbol_native"],
skip,
take
}
)

// do something with the currencies or return them
}

Parameters

The filters to apply on the retrieved currencies.
The configurations determining how the currencies are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a currency.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<CurrencyDTO[]>

PromisePromise<CurrencyDTO[]>Required
The list of currencies.

listMoneyAmounts

**listMoneyAmounts**(filters?, config?, sharedContext?): Promise&#60;[MoneyAmountDTO](/references/services/interfaces/MoneyAmountDTO)[]&#62;

This method is used to retrieve a paginated list of money amounts based on optional filters and configuration.

Example

To retrieve a list of money amounts using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const moneyAmounts = await pricingService.listMoneyAmounts(
{
$and: [
{
id: moneyAmountIds
},
{
currency_code: currencyCode
}
]
},
{
relations: ["currency"],
skip,
take
}
)

// do something with the money amounts or return them
}

Parameters

The filtes to apply on the retrieved money amounts.
The configurations determining how the money amounts are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<MoneyAmountDTO[]>

PromisePromise<MoneyAmountDTO[]>Required
The list of money amounts.

listPriceListRules

**listPriceListRules**(filters?, config?, sharedContext?): Promise&#60;[PriceListRuleDTO](/references/services/interfaces/PriceListRuleDTO)[]&#62;

This method is used to retrieve a paginated list of price list rules based on optional filters and configuration.

Example

To retrieve a list of price list vs using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceListRules (priceListRuleIds: string[]) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.listPriceListRules(
{
id: priceListRuleIds
},
)

// do something with the price list rules or return them
}

To specify relations that should be retrieved within the price list rules:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceListRules (priceListRuleIds: string[]) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.listPriceListRules(
{
id: priceListRuleIds
},
{
relations: ["price_list_rule_values"]
}
)

// do something with the price list 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceListRules (priceListRuleIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.listPriceListRules(
{
id: priceListRuleIds
},
{
relations: ["price_list_rule_values"],
skip,
take
}
)

// do something with the price list 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceListRules (priceListRuleIds: string[], ruleTypeIDs: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.listPriceListRules(
{
$and: [
{
id: priceListRuleIds
},
{
rule_types: ruleTypeIDs
}
]
},
{
relations: ["price_list_rule_values"],
skip,
take
}
)

// do something with the price list rules or return them
}

Parameters

The filters to apply on the retrieved price list rules.
The configurations determining how the price list rules are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListRuleDTO[]>

PromisePromise<PriceListRuleDTO[]>Required
The list of price list rules.

listPriceLists

**listPriceLists**(filters?, config?, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)[]&#62;

This method is used to retrieve a paginated list of price lists based on optional filters and configuration.

Example

To retrieve a list of price lists using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceLists (priceListIds: string[]) {
const pricingService = await initializePricingModule()

const priceLists = await pricingService.listPriceLists(
{
id: priceListIds
},
)

// do something with the price lists or return them
}

To specify relations that should be retrieved within the price lists:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceLists (priceListIds: string[]) {
const pricingService = await initializePricingModule()

const priceLists = await pricingService.listPriceLists(
{
id: priceListIds
},
{
relations: ["price_set_money_amounts"]
}
)

// do something with the price lists 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceLists (priceListIds: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceLists = await pricingService.listPriceLists(
{
id: priceListIds
},
{
relations: ["price_set_money_amounts"],
skip,
take
}
)

// do something with the price lists 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function listPriceLists (priceListIds: string[], titles: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceLists = await pricingService.listPriceLists(
{
$and: [
{
id: priceListIds
},
{
title: titles
}
]
},
{
relations: ["price_set_money_amounts"],
skip,
take
}
)

// do something with the price lists or return them
}

Parameters

The filters to apply on the retrieved price lists.
The configurations determining how the price lists are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO[]>

PromisePromise<PriceListDTO[]>Required
The list of price lists.

listPriceRules

**listPriceRules**(filters?, config?, sharedContext?): Promise&#60;[PriceRuleDTO](/references/services/interfaces/PriceRuleDTO)[]&#62;

This method is used to retrieve a paginated list of price rules based on optional filters and configuration.

Example

To retrieve a list of price rules using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceRules = await pricingService.listPriceRules({
$and: [
{
id: ids
},
{
name
}
]
}, {
relations: ["price_set"],
skip,
take
})

// do something with the price rules or return them
}

Parameters

The filters to apply on the retrieved price rules.
The configurations determining how the price rule is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceRuleDTO[]>

PromisePromise<PriceRuleDTO[]>Required
The list of price rules.

listPriceSetMoneyAmountRules

**listPriceSetMoneyAmountRules**(filters?, config?, sharedContext?): Promise&#60;[PriceSetMoneyAmountRulesDTO](/references/services/interfaces/PriceSetMoneyAmountRulesDTO)[]&#62;

This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration.

Example

To retrieve a list of price set money amount rules using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({
$and: [
{
id: ids
},
{
rule_type_id: ruleTypeId
}
]
}, {
relations: ["price_set_money_amount"],
skip,
take
})

// do something with the price set money amount rules or return them
}

Parameters

The filters to apply on the retrieved price set money amount rules.
The configurations determining how the price set money amount rules are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set money amount rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetMoneyAmountRulesDTO[]>

PromisePromise<PriceSetMoneyAmountRulesDTO[]>Required
The list of price set money amount rules.

listPriceSetMoneyAmounts

**listPriceSetMoneyAmounts**(filters?, config?, sharedContext?): Promise&#60;[PriceSetMoneyAmountDTO](/references/services/interfaces/PriceSetMoneyAmountDTO)[]&#62;

This method is used to retrieve a paginated list of price set money amounts based on optional filters and configuration.

Example

To retrieve a list of price set money amounts using their IDs:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
id: [id]
})

// do something with the price set money amounts or return them
}

To specify relations that should be retrieved within the price set money amounts:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"]
})

// do something with the price set 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string, skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set 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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (ids: string[], titles: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
$and: [
{
id: ids
},
{
title: titles
}
]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set money amounts or return them
}

Parameters

The filters to apply on the retrieved price set money amounts.
The configurations determining how the price set money amounts are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetMoneyAmountDTO[]>

PromisePromise<PriceSetMoneyAmountDTO[]>Required
The list of price set money amounts.

listRuleTypes

**listRuleTypes**(filters?, config?, sharedContext?): Promise&#60;[RuleTypeDTO](/references/services/interfaces/RuleTypeDTO)[]&#62;

This method is used to retrieve a paginated list of rule types based on optional filters and configuration.

Example

To retrieve a list of rule types using their IDs:

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:

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:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const ruleTypes = await pricingService.listRuleTypes({
$and: [
{
id: ruleTypeId
},
{
name
}
]
}, {
select: ["name"],
skip,
take
})

// do something with the rule types or return them
}

Parameters

The filters to apply on the retrieved rule types.
The configurations determining how the rule types are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a rule type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<RuleTypeDTO[]>

PromisePromise<RuleTypeDTO[]>Required
The list of rule types.

removePriceListRules

**removePriceListRules**(data, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)&#62;

This method is used to remove rules from a price list.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function setPriceListRules (priceListId: string) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.removePriceListRules({
priceListId,
rules: ["region_id"]
})

// do something with the price list or return it
}

Parameters

The rules to remove from a price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO>

PromisePromise<PriceListDTO>Required
The updated price lists.

removeRules

**removeRules**(data, sharedContext?): Promise&#60;void&#62;

This method remove rules from a price set.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function removePriceSetRule (priceSetId: string, ruleAttributes: []) {
const pricingService = await initializePricingModule()

await pricingService.removeRules([
{
id: priceSetId,
rules: ruleAttributes
},
])
}

Parameters

The rules to remove per price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when rules are successfully removed.

retrieve

**retrieve**(id, config?, sharedContext?): Promise&#60;[PriceSetDTO](/references/services/interfaces/PriceSetDTO)&#62;

This method is used to retrieve a price set by its ID.

Example

A simple example that retrieves a price set by its ID:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSet = await pricingService.retrieve(
priceSetId,
{
relations: ["money_amounts"]
}
)

// do something with the price set or return it
}

Parameters

idstringRequired
The ID of the price set to retrieve.
The configurations determining how the price set is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetDTO>

PromisePromise<PriceSetDTO>Required
The retrieved price set.

retrieveCurrency

**retrieveCurrency**(code, config?, sharedContext?): Promise&#60;[CurrencyDTO](/references/services/interfaces/CurrencyDTO)&#62;

This method retrieves a currency by its code and and optionally based on the provided configurations.

Example

A simple example that retrieves a currency by its code:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveCurrency (code: string) {
const pricingService = await initializePricingModule()

const currency = await pricingService.retrieveCurrency(
code,
{
select: ["symbol_native"]
}
)

// do something with the currency or return it
}

Parameters

codestringRequired
The code of the currency to retrieve.
The configurations determining how the currency is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a currency.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<CurrencyDTO>

PromisePromise<CurrencyDTO>Required
The retrieved currency.

retrieveMoneyAmount

**retrieveMoneyAmount**(id, config?, sharedContext?): Promise&#60;[MoneyAmountDTO](/references/services/interfaces/MoneyAmountDTO)&#62;

This method retrieves a money amount by its ID.

Example

To retrieve a money amount by its ID:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveMoneyAmount (moneyAmountId: string) {
const pricingService = await initializePricingModule()

const moneyAmount = await pricingService.retrieveMoneyAmount(
moneyAmountId,
{
relations: ["currency"]
}
)

// do something with the money amount or return it
}

Parameters

idstringRequired
The ID of the money amount to retrieve.
The configurations determining how a money amount is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<MoneyAmountDTO>

PromisePromise<MoneyAmountDTO>Required
The retrieved money amount.

retrievePriceList

**retrievePriceList**(id, config?, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)&#62;

This method is used to retrieve a price list by its ID.

Example

A simple example that retrieves a price list by its ID:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceList (priceListId: string) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.retrievePriceList(
priceListId
)

// do something with the price list or return it
}

To specify relations that should be retrieved:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceList (priceListId: string) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.retrievePriceList(
priceListId,
{
relations: ["price_set_money_amounts"]
}
)

// do something with the price list or return it
}

Parameters

idstringRequired
The ID of the price list to retrieve.
The configurations determining how the price list is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO>

PromisePromise<PriceListDTO>Required
The retrieved price list.

retrievePriceListRule

**retrievePriceListRule**(id, config?, sharedContext?): Promise&#60;[PriceListRuleDTO](/references/services/interfaces/PriceListRuleDTO)&#62;

This method is used to retrieve a price list rule by its ID.

Example

A simple example that retrieves a price list rule by its ID:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceListRule (priceListRuleId: string) {
const pricingService = await initializePricingModule()

const priceListRule = await pricingService.retrievePriceListRule(
priceListRuleId
)

// do something with the price list rule or return it
}

To specify relations that should be retrieved:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceListRule (priceListRuleId: string) {
const pricingService = await initializePricingModule()

const priceListRule = await pricingService.retrievePriceListRule(
priceListRuleId,
{
relations: ["price_list"]
}
)

// do something with the price list rule or return it
}

Parameters

idstringRequired
The ID of the price list rule to retrieve.
The configurations determining how the price list rule is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price list rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListRuleDTO>

PromisePromise<PriceListRuleDTO>Required
The retrieved price list rule.

retrievePriceRule

**retrievePriceRule**(id, config?, sharedContext?): Promise&#60;[PriceRuleDTO](/references/services/interfaces/PriceRuleDTO)&#62;

This method is used to retrieve a price rule by its ID.

Example

A simple example that retrieves a price rule by its ID:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceRule (id: string) {
const pricingService = await initializePricingModule()

const priceRule = await pricingService.retrievePriceRule(id, {
relations: ["price_set"]
})

// do something with the price rule or return it
}

Parameters

idstringRequired
The ID of the price rule to retrieve.
The configurations determining how the price rule is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceRuleDTO>

PromisePromise<PriceRuleDTO>Required
The retrieved price rule.

retrievePriceSetMoneyAmountRules

**retrievePriceSetMoneyAmountRules**(id, config?, sharedContext?): Promise&#60;[PriceSetMoneyAmountRulesDTO](/references/services/interfaces/PriceSetMoneyAmountRulesDTO)&#62;

This method is used to a price set money amount rule by its ID based on the provided configuration.

Example

A simple example that retrieves a price set money amount rule by its ID:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmountRule (id: string) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id, {
relations: ["price_set_money_amount"]
})

// do something with the price set money amount rule or return it
}

Parameters

idstringRequired
The ID of the price set money amount rule to retrieve.
The configurations determining how the price set money amount rule is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a price set money amount rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetMoneyAmountRulesDTO>

PromisePromise<PriceSetMoneyAmountRulesDTO>Required
The retrieved price set money amount rule.

retrieveRuleType

**retrieveRuleType**(id, config?, sharedContext?): Promise&#60;[RuleTypeDTO](/references/services/interfaces/RuleTypeDTO)&#62;

This method is used to retrieve a rule type by its ID and and optionally based on the provided configurations.

Example

A simple example that retrieves a rule type by its code:

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:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveRuleType (ruleTypeId: string) {
const pricingService = await initializePricingModule()

const ruleType = await pricingService.retrieveRuleType(ruleTypeId, {
select: ["name"]
})

// do something with the rule type or return it
}

Parameters

idstringRequired
The ID of the rule type to retrieve.
The configurations determining how the rule type is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a rule type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<RuleTypeDTO>

PromisePromise<RuleTypeDTO>Required
The retrieved rule type.

setPriceListRules

**setPriceListRules**(data, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)&#62;

This method is used to set the rules of a price list.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function setPriceListRules (priceListId: string) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.setPriceListRules({
priceListId,
rules: {
region_id: "US"
}
})

// do something with the price list or return it
}

Parameters

The rules to set for a price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO>

PromisePromise<PriceListDTO>Required
The updated price lists.

updateCurrencies

**updateCurrencies**(data, sharedContext?): Promise&#60;[CurrencyDTO](/references/services/interfaces/CurrencyDTO)[]&#62;

This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update.

Example

import { initialize as initializePricingModule } from "@medusajs/pricing"

async function updateCurrencies() {
const pricingService = await initializePricingModule()

const currencies = await pricingService.updateCurrencies([
{
code: "USD",
symbol: "$",
},
])

// do something with the currencies or return them
}

Parameters

dataUpdateCurrencyDTO[]Required
The currencies to update, each having the attributes that should be updated in a currency.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<CurrencyDTO[]>

PromisePromise<CurrencyDTO[]>Required
The list of updated currencies.

updateMoneyAmounts

**updateMoneyAmounts**(data, sharedContext?): Promise&#60;[MoneyAmountDTO](/references/services/interfaces/MoneyAmountDTO)[]&#62;

This method updates existing money amounts.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updateMoneyAmounts (moneyAmountId: string, amount: number) {
const pricingService = await initializePricingModule()

const moneyAmounts = await pricingService.updateMoneyAmounts([
{
id: moneyAmountId,
amount
}
])

// do something with the money amounts or return them
}

Parameters

dataUpdateMoneyAmountDTO[]Required
The money amounts to update, each having the attributes that should be updated in a money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<MoneyAmountDTO[]>

PromisePromise<MoneyAmountDTO[]>Required
The list of updated money amounts.

updatePriceListRules

**updatePriceListRules**(data, sharedContext?): Promise&#60;[PriceListRuleDTO](/references/services/interfaces/PriceListRuleDTO)[]&#62;

This method is used to update price list rules.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updatePriceListRules (items: {
id: string
rule_type_id?: string
price_list_id?: string
}[]) {
const pricingService = await initializePricingModule()

const priceListRules = await pricingService.updatePriceListRules(items)

// do something with the price list rule or return them
}

Parameters

The attributes to update for each price list rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListRuleDTO[]>

PromisePromise<PriceListRuleDTO[]>Required
The updated price list rules.

updatePriceLists

**updatePriceLists**(data, sharedContext?): Promise&#60;[PriceListDTO](/references/services/interfaces/PriceListDTO)[]&#62;

This method is used to update price lists.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updatePriceLists (items: {
id: string
title: string
description: string
starts_at?: string
ends_at?: string
}[]) {
const pricingService = await initializePricingModule()

const priceList = await pricingService.updatePriceLists(items)

// do something with the price lists or return them
}

Parameters

dataUpdatePriceListDTO[]Required
The attributes to update in each price list.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceListDTO[]>

PromisePromise<PriceListDTO[]>Required
The updated price lists.

updatePriceRules

**updatePriceRules**(data, sharedContext?): Promise&#60;[PriceRuleDTO](/references/services/interfaces/PriceRuleDTO)[]&#62;

This method is used to update price rules, each with their provided data.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updatePriceRules (
id: string,
priceSetId: string,
) {
const pricingService = await initializePricingModule()

const priceRules = await pricingService.updatePriceRules([
{
id,
price_set_id: priceSetId,
}
])

// do something with the price rules or return them
}

Parameters

dataUpdatePriceRuleDTO[]Required
The price rules to update, each having attributes that should be updated in a price rule.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceRuleDTO[]>

PromisePromise<PriceRuleDTO[]>Required
The list of updated price rules.

updatePriceSetMoneyAmountRules

**updatePriceSetMoneyAmountRules**(data, sharedContext?): Promise&#60;[PriceSetMoneyAmountRulesDTO](/references/services/interfaces/PriceSetMoneyAmountRulesDTO)[]&#62;

This method is used to update price set money amount rules, each with their provided data.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updatePriceSetMoneyAmountRules (id: string, value: string) {
const pricingService = await initializePricingModule()

const priceSetMoneyAmountRules = await pricingService.updatePriceSetMoneyAmountRules([
{
id,
value
}
])

// do something with the price set money amount rules or return them
}

Parameters

The price set money amounts to update, each having the attributes to update in a price set money amount.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<PriceSetMoneyAmountRulesDTO[]>

PromisePromise<PriceSetMoneyAmountRulesDTO[]>Required
The list of updated price set money amount rules.

updateRuleTypes

**updateRuleTypes**(data, sharedContext?): Promise&#60;[RuleTypeDTO](/references/services/interfaces/RuleTypeDTO)[]&#62;

This method is used to update existing rule types with the provided data.

Example

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function updateRuleTypes (ruleTypeId: string) {
const pricingService = await initializePricingModule()

const ruleTypes = await pricingService.updateRuleTypes([
{
id: ruleTypeId,
name: "Region",
}
])

// do something with the rule types or return them
}

Parameters

dataUpdateRuleTypeDTO[]Required
The rule types to update, each having the attributes that should be updated in a rule type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<RuleTypeDTO[]>

PromisePromise<RuleTypeDTO[]>Required
The list of updated rule types.
Was this section helpful?