Skip to main content
Skip to main content

retrievePriceRule - Pricing Module Reference

Beta

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

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

Example

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

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

PromisePromise<PriceRuleDTO>Required
The retrieved price rule.
Was this section helpful?