Skip to main content
Skip to main content

listPriceSetMoneyAmountRules - Pricing Module Reference

Beta

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

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

Example

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

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

PromisePromise<PriceSetMoneyAmountRulesDTO[]>Required
The list of price set money amount rules.
Was this section helpful?