* adjusted configurations * enhancements to tool and configurations * change reference in docs * fixed issue in workflows reference * added project name * more optimizations * fix context error * added a types reference * resolved missing types * fix reference reflection types not having children * add an expand url parameter * added new option to the README * added details about new option
370 lines
12 KiB
Plaintext
370 lines
12 KiB
Plaintext
---
|
|
displayed_sidebar: pricingReference
|
|
badge:
|
|
variant: orange
|
|
text: Beta
|
|
slug: /references/pricing/retrieveMoneyAmount
|
|
sidebar_label: retrieveMoneyAmount
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# retrieveMoneyAmount - Pricing Module Reference
|
|
|
|
This documentation provides a reference to the `retrieveMoneyAmount` method. This belongs to the Pricing Module.
|
|
|
|
This method retrieves a money amount by its ID.
|
|
|
|
## Example
|
|
|
|
To retrieve a money amount by its ID:
|
|
|
|
```ts
|
|
import {
|
|
initialize as initializePricingModule,
|
|
} from "@medusajs/pricing"
|
|
|
|
async function retrieveMoneyAmount (moneyAmountId: string) {
|
|
const pricingService = await initializePricingModule()
|
|
|
|
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
|
moneyAmountId,
|
|
)
|
|
|
|
// do something with the money amount or return it
|
|
}
|
|
```
|
|
|
|
To retrieve relations along with the money amount:
|
|
|
|
```ts
|
|
import {
|
|
initialize as initializePricingModule,
|
|
} from "@medusajs/pricing"
|
|
|
|
async function retrieveMoneyAmount (moneyAmountId: string) {
|
|
const pricingService = await initializePricingModule()
|
|
|
|
const moneyAmount = await pricingService.retrieveMoneyAmount(
|
|
moneyAmountId,
|
|
{
|
|
relations: ["currency"]
|
|
}
|
|
)
|
|
|
|
// do something with the money amount or return it
|
|
}
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the money amount to retrieve.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "config",
|
|
"type": "[FindConfig](../../pricing/interfaces/pricing.FindConfig.mdx)<[MoneyAmountDTO](../../pricing/interfaces/pricing.MoneyAmountDTO.mdx)>",
|
|
"description": "The configurations determining how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the\nattributes or relations associated with a money amount.",
|
|
"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<[MoneyAmountDTO](../../pricing/interfaces/pricing.MoneyAmountDTO.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "The retrieved money amount.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "amount",
|
|
"type": "`number`",
|
|
"description": "The price of this money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "currency",
|
|
"type": "[CurrencyDTO](../../pricing/interfaces/pricing.CurrencyDTO.mdx)",
|
|
"description": "The money amount's currency.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": [
|
|
{
|
|
"name": "code",
|
|
"type": "`string`",
|
|
"description": "The code of the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The name of the currency.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol",
|
|
"type": "`string`",
|
|
"description": "The symbol of the currency.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol_native",
|
|
"type": "`string`",
|
|
"description": "The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "currency_code",
|
|
"type": "`string`",
|
|
"description": "The currency code of this money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the money amount.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "max_quantity",
|
|
"type": "`number`",
|
|
"description": "The maximum quantity required to be purchased for this price to be applied.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "min_quantity",
|
|
"type": "`number`",
|
|
"description": "The minimum quantity required to be purchased for this price to be applied.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "price_set_money_amount",
|
|
"type": "[PriceSetMoneyAmountDTO](../../pricing/interfaces/pricing.PriceSetMoneyAmountDTO.mdx)",
|
|
"description": "The details of the relation between the money amount and its associated price set.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of a price set money amount.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "money_amount",
|
|
"type": "[MoneyAmountDTO](../../pricing/interfaces/pricing.MoneyAmountDTO.mdx)",
|
|
"description": "The money amount associated with the price set money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "price_list",
|
|
"type": "[PriceListDTO](../../pricing/interfaces/pricing.PriceListDTO.mdx)",
|
|
"description": "The price list associated with the price set money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "price_rules",
|
|
"type": "[PriceRuleDTO](../../pricing/interfaces/pricing.PriceRuleDTO.mdx)[]",
|
|
"description": "The price rules associated with the price set money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "price_set",
|
|
"type": "[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)",
|
|
"description": "The price set associated with the price set money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": true,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "price_set_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the associated price set.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "title",
|
|
"type": "`string`",
|
|
"description": "The title of the price set money amount.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|