---
displayed_sidebar: pricingReference
badge:
  variant: orange
  text: Beta
slug: /references/pricing/retrievePriceListRule
sidebar_label: retrievePriceListRule
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# retrievePriceListRule - Pricing Module Reference

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

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:

```ts
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:

```ts
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

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "The ID of the price list rule to retrieve.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../../pricing/interfaces/pricing.FindConfig.mdx)&#60;[PriceListRuleDTO](../../pricing/interfaces/pricing.PriceListRuleDTO.mdx)&#62;",
    "description": "The configurations determining how the price list rule is retrieved. Its properties, such as `select` or `relations`, accept the\nattributes or relations associated with a price list rule.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "order",
        "type": "`object`",
        "description": "An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "relations",
        "type": "`string`[]",
        "description": "An array of strings, each being relation names of the entity to retrieve in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "select",
        "type": "(`string` \\| keyof `Entity`)[]",
        "description": "An array of strings, each being attribute names of the entity to retrieve in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "skip",
        "type": "`null` \\| `number`",
        "description": "A number indicating the number of records to skip before retrieving the results.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "take",
        "type": "`null` \\| `number`",
        "description": "A number indicating the number of records to return in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "withDeleted",
        "type": "`boolean`",
        "description": "A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "sharedContext",
    "type": "[Context](../../pricing/interfaces/pricing.Context.mdx)",
    "description": "A context used to share resources, such as transaction manager, between the application and the module.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "enableNestedTransactions",
        "type": "`boolean`",
        "description": "A boolean value indicating whether nested transactions are enabled.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "isolationLevel",
        "type": "`string`",
        "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "manager",
        "type": "`TManager`",
        "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionId",
        "type": "`string`",
        "description": "A string indicating the ID of the current transaction.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionManager",
        "type": "`TManager`",
        "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />

## Returns

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[PriceListRuleDTO](../../pricing/interfaces/pricing.PriceListRuleDTO.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "The retrieved price list rule.",
    "expandable": false,
    "children": [
      {
        "name": "id",
        "type": "`string`",
        "description": "The price list rule's ID.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "price_list",
        "type": "[PriceListDTO](../../pricing/interfaces/pricing.PriceListDTO.mdx)",
        "description": "The associated price list.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": [
          {
            "name": "ends_at",
            "type": "`null` \\| `string`",
            "description": "The price list expires after this date.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "id",
            "type": "`string`",
            "description": "The price list's ID.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "money_amounts",
            "type": "[MoneyAmountDTO](../../pricing/interfaces/pricing.MoneyAmountDTO.mdx)[]",
            "description": "The associated money amounts.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "number_rules",
            "type": "`number`",
            "description": "The number of rules associated with this price list.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "price_list_rules",
            "type": "[PriceListRuleDTO](../../pricing/interfaces/pricing.PriceListRuleDTO.mdx)[]",
            "description": "The price set's rules.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "price_set_money_amounts",
            "type": "[PriceSetMoneyAmountDTO](../../pricing/interfaces/pricing.PriceSetMoneyAmountDTO.mdx)[]",
            "description": "The associated price set money amounts.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "rule_types",
            "type": "[RuleTypeDTO](../../pricing/interfaces/pricing.RuleTypeDTO.mdx)[]",
            "description": "The associated rule types.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "rules",
            "type": "[PriceListRuleDTO](../../pricing/interfaces/pricing.PriceListRuleDTO.mdx)[]",
            "description": "The price set's rules.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "starts_at",
            "type": "`null` \\| `string`",
            "description": "The price list is enabled starting from this date.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "status",
            "type": "[PriceListStatus](../../pricing/enums/pricing.PriceListStatus.mdx)",
            "description": "The price list's status.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "title",
            "type": "`string`",
            "description": "The price list's title.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "price_list_rule_values",
        "type": "[PriceListRuleValueDTO](../../pricing/interfaces/pricing.PriceListRuleValueDTO.mdx)[]",
        "description": "The associated rule values.",
        "optional": true,
        "defaultValue": "",
        "expandable": true,
        "children": [
          {
            "name": "id",
            "type": "`string`",
            "description": "The price list rule value's ID.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "price_list_rule",
            "type": "[PriceListRuleDTO](../../pricing/interfaces/pricing.PriceListRuleDTO.mdx)",
            "description": "The associated price list rule.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "value",
            "type": "`string`",
            "description": "The rule's value.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "rule_type",
        "type": "[RuleTypeDTO](../../pricing/interfaces/pricing.RuleTypeDTO.mdx)",
        "description": "The associated rule type.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": [
          {
            "name": "default_priority",
            "type": "`number`",
            "description": "The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy \nthe provided context. The higher the value, the higher the priority of the rule type.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "id",
            "type": "`string`",
            "description": "The ID of the rule type.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "name",
            "type": "`string`",
            "description": "The display name of the rule type.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "rule_attribute",
            "type": "`string`",
            "description": "The unique name used to later identify the rule\\_attribute. For example, it can be used in the `context` parameter of \nthe `calculatePrices` method to specify a rule for calculating the price.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "value",
        "type": "`string`",
        "description": "The value of the rule.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />
