Skip to main content
Skip to main content

listMoneyAmounts - Pricing Module Reference

Beta

This documentation provides a reference to the listMoneyAmounts method. This belongs to the Pricing Module.

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

Example

To retrieve a list of money amounts using their IDs:

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

PromisePromise<MoneyAmountDTO[]>Required
The list of money amounts.
Was this section helpful?