Skip to main content
Skip to main content

retrieveRuleType - Pricing Module Reference

Beta

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

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

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

PromisePromise<RuleTypeDTO>Required
The retrieved rule type.
Was this section helpful?