Files
medusa-store/www/apps/docs/content/references/services/classes/services.PricingService.mdx
github-actions[bot] 5a550e73b4 chore(docs): Generated References (#6222)
Generated the following references:
- `entities`
- `file`
- `fulfillment`
- `inventory`
- `js_client`
- `medusa`
- `medusa_config`
- `medusa_react`
- `modules`
- `notification`
- `payment`
- `price_selection`
- `pricing`
- `product`
- `search`
- `services`
- `stock_location`
- `tax`
- `tax_calculation`
- `types`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2024-01-25 18:12:27 +00:00

284 lines
20 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# PricingService
Allows retrieval of prices.
## constructor
### Parameters
<ParameterTypes parameters={[{"name":"__namedParameters","type":"`InjectedDependencies`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="new PricingService"/>
___
## Properties
<ParameterTypes parameters={[{"name":"manager_","type":"`EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionManager_","type":"`undefined` \\| `EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"__container__","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionService","type":"[RegionService](services.RegionService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"taxProviderService","type":"[TaxProviderService](services.TaxProviderService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerService_","type":"[CustomerService](services.CustomerService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"priceSelectionStrategy","type":"[IPriceSelectionStrategy](../../medusa/interfaces/medusa.IPriceSelectionStrategy.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"productVariantService","type":"[ProductVariantService](services.ProductVariantService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"featureFlagRouter","type":"`FlagRouter`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"__configModule__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="PricingService"/>
___
## Accessors
### activeManager\_
#### Returns
<ParameterTypes parameters={[{"name":"EntityManager","type":"`EntityManager`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="activeManager_"/>
### pricingModuleService
#### Returns
<ParameterTypes parameters={[{"name":"IPricingModuleService","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="pricingModuleService"/>
### remoteQuery
#### Returns
<ParameterTypes parameters={[{"name":"RemoteQueryFunction","type":"(`query`: `string` \\| [RemoteJoinerQuery](../../types/interfaces/types.RemoteJoinerQuery.mdx) \\| `object`, `variables?`: `Record<string, unknown>`) => Promise&#60;any&#62; \\| `null`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="remoteQuery"/>
___
## Methods
### withTransaction
#### Parameters
<ParameterTypes parameters={[{"name":"transactionManager","type":"`EntityManager`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
#### Returns
<ParameterTypes parameters={[{"name":"this","type":"`this`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
### shouldRetryTransaction\_
#### Parameters
<ParameterTypes parameters={[{"name":"err","type":"`Record<string, unknown>` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
#### Returns
<ParameterTypes parameters={[{"name":"boolean","type":"`boolean`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
### atomicPhase\_
Wraps some work within a transactional block. If the service already has
a transaction manager attached this will be reused, otherwise a new
transaction manager is created.
#### Type Parameters
<ParameterTypes parameters={[{"name":"TResult","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TError","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
#### Parameters
<ParameterTypes parameters={[{"name":"work","type":"(`transactionManager`: `EntityManager`) => Promise&#60;TResult&#62;","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise&#60;void \\| TResult&#62;","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise&#60;void \\| TResult&#62;","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;TResult&#62;","optional":false,"defaultValue":"","description":"the result of the transactional work","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
### collectPricingContext
Collects additional information necessary for completing the price
selection.
#### Parameters
<ParameterTypes parameters={[{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="collectPricingContext"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;PricingContext&#62;","optional":false,"defaultValue":"","description":"The pricing context","expandable":false,"children":[]}]} sectionTitle="collectPricingContext"/>
### calculateTaxes
Gets the prices for a product variant
#### Parameters
<ParameterTypes parameters={[{"name":"variantPricing","type":"[ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)","description":"the prices retrieved from a variant","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"productRates","type":"[TaxServiceRate](../../medusa/types/medusa.TaxServiceRate.mdx)[]","description":"the tax rates that the product has applied","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="calculateTaxes"/>
#### Returns
<ParameterTypes parameters={[{"name":"TaxedPricing","type":"`object`","description":"Pricing fields related to taxes.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="calculateTaxes"/>
### getProductVariantPricingModulePricing\_
#### Parameters
<ParameterTypes parameters={[{"name":"variantPriceData","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricingModulePricing_"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Map&#60;any, any&#62;&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricingModulePricing_"/>
### getProductVariantPricing\_
#### Parameters
<ParameterTypes parameters={[{"name":"data","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricing_"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Map&#60;string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricing_"/>
### getProductVariantPricing
Gets the prices for a product variant.
#### Parameters
<ParameterTypes parameters={[{"name":"variant","type":"Pick&#60;[ProductVariant](../../entities/classes/entities.ProductVariant.mdx), \"id\" \\| \"product_id\"&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx) \\| [PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;","optional":false,"defaultValue":"","description":"The product variant prices","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricing"/>
### getProductVariantPricingById
Gets the prices for a product variant by a variant id.
#### Parameters
<ParameterTypes parameters={[{"name":"variantId","type":"`string`","description":"the id of the variant to get prices for","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx) \\| [PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricingById"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;","optional":false,"defaultValue":"","description":"The product variant prices","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricingById"/>
#### Deprecated
Use [getProductVariantsPricing](services.PricingService.mdx#getproductvariantspricing) instead.
### getProductVariantsPricing
Gets the prices for a collection of variants.
#### Parameters
<ParameterTypes parameters={[{"name":"data","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx) \\| [PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantsPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;object&#62;","optional":false,"defaultValue":"","description":"The product variant prices","expandable":false,"children":[]}]} sectionTitle="getProductVariantsPricing"/>
### getProductPricing\_
#### Parameters
<ParameterTypes parameters={[{"name":"data","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductPricing_"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Map&#60;string, Record&#60;string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;&#62;&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getProductPricing_"/>
### getProductPricing
Gets all the variant prices for a product. All the product's variants will
be fetched.
#### Parameters
<ParameterTypes parameters={[{"name":"product","type":"Pick&#60;[Product](../../entities/classes/entities.Product.mdx), \"id\" \\| \"variants\"&#62;","description":"the product to get pricing for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Record&#60;string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;&#62;","optional":false,"defaultValue":"","description":"A map of variant ids to their corresponding prices","expandable":false,"children":[]}]} sectionTitle="getProductPricing"/>
### getProductPricingById
Gets all the variant prices for a product by the product id
#### Parameters
<ParameterTypes parameters={[{"name":"productId","type":"`string`","description":"the id of the product to get prices for","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getProductPricingById"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Record&#60;string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)&#62;&#62;","optional":false,"defaultValue":"","description":"A map of variant ids to their corresponding prices","expandable":false,"children":[]}]} sectionTitle="getProductPricingById"/>
### setVariantPrices
Set additional prices on a list of product variants.
#### Parameters
<ParameterTypes parameters={[{"name":"variants","type":"[ProductVariant](../../entities/classes/entities.ProductVariant.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="setVariantPrices"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]&#62;","optional":false,"defaultValue":"","description":"A list of products with variants decorated with prices","expandable":false,"children":[]}]} sectionTitle="setVariantPrices"/>
### setProductPrices
Set additional prices on a list of products.
#### Parameters
<ParameterTypes parameters={[{"name":"products","type":"[Product](../../entities/classes/entities.Product.mdx)[]","description":"list of products on which to set additional prices","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="setProductPrices"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;([Product](../../entities/classes/entities.Product.mdx) \\| [PricedProduct](../../medusa/types/medusa.PricedProduct.mdx))[]&#62;","optional":false,"defaultValue":"","description":"A list of products with variants decorated with prices","expandable":false,"children":[]}]} sectionTitle="setProductPrices"/>
### getPricingModuleVariantMoneyAmounts
#### Parameters
<ParameterTypes parameters={[{"name":"variantIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getPricingModuleVariantMoneyAmounts"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;Map&#60;string, [MoneyAmount](../../entities/classes/entities.MoneyAmount.mdx)[]&#62;&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getPricingModuleVariantMoneyAmounts"/>
### setAdminVariantPricing
#### Parameters
<ParameterTypes parameters={[{"name":"variants","type":"[ProductVariant](../../entities/classes/entities.ProductVariant.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx)","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="setAdminVariantPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="setAdminVariantPricing"/>
### setAdminProductPricing
#### Parameters
<ParameterTypes parameters={[{"name":"products","type":"[Product](../../entities/classes/entities.Product.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="setAdminProductPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;([Product](../../entities/classes/entities.Product.mdx) \\| [PricedProduct](../../medusa/types/medusa.PricedProduct.mdx))[]&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="setAdminProductPricing"/>
### getShippingOptionPricing
Gets the prices for a shipping option.
#### Parameters
<ParameterTypes parameters={[{"name":"shippingOption","type":"[ShippingOption](../../entities/classes/entities.ShippingOption.mdx)","description":"the shipping option to get prices for","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx) \\| [PricingContext](../../types/interfaces/types.PricingContext.mdx)","description":"the price selection context to use","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getShippingOptionPricing"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)&#62;","optional":false,"defaultValue":"","description":"The shipping option prices","expandable":false,"children":[]}]} sectionTitle="getShippingOptionPricing"/>
### setShippingOptionPrices
Set additional prices on a list of shipping options.
#### Parameters
<ParameterTypes parameters={[{"name":"shippingOptions","type":"[ShippingOption](../../entities/classes/entities.ShippingOption.mdx)[]","description":"list of shipping options on which to set additional prices","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"Omit&#60;[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx), \"region_id\"&#62;","description":"the price selection context to use","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="setShippingOptionPrices"/>
#### Returns
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)[]&#62;","optional":false,"defaultValue":"","description":"A list of shipping options with prices","expandable":false,"children":[]}]} sectionTitle="setShippingOptionPrices"/>