This PR includes documentation that preps for v2 docs (but doesn't introduce new docs). _Note: The number of file changes in the PR is due to find-and-replace within the `references` which is unavoidable. Let me know if I should move it to another PR._ ## Changes - Change Medusa version in base OAS used for v2. - Fix to docblock generator related to not catching all path parameters. - Added typedoc plugin that generates ER Diagrams, which will be used specifically for data model references in commerce modules. - Changed OAS tool to output references in `www/apps/api-reference/specs-v2` directory when the `--v2` option is used. - Added a version switcher to the API reference to switch between V1 and V2. This switcher is enabled by an environment variable, so it won't be visible/usable at the moment. - Upgraded docusaurus to v3.0.1 - Added new Vale rules to ensure correct spelling of Medusa Admin and module names. - Added new components to the `docs-ui` package that will be used in future documentation changes.
284 lines
19 KiB
Plaintext
284 lines
19 KiB
Plaintext
---
|
|
displayed_sidebar: servicesSidebar
|
|
---
|
|
|
|
import TypeList from "@site/src/components/TypeList"
|
|
|
|
# PricingService
|
|
|
|
Allows retrieval of prices.
|
|
|
|
## constructor
|
|
|
|
### Parameters
|
|
|
|
<TypeList types={[{"name":"__namedParameters","type":"`InjectedDependencies`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="new PricingService"/>
|
|
|
|
___
|
|
|
|
## Properties
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"EntityManager","type":"`EntityManager`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="activeManager_"/>
|
|
|
|
### pricingModuleService
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"IPricingModuleService","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="pricingModuleService"/>
|
|
|
|
### remoteQuery
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"RemoteQueryFunction","type":"(`query`: `string` \\| [RemoteJoinerQuery](../../types/interfaces/types.RemoteJoinerQuery.mdx) \\| `object`, `variables?`: `Record<string, unknown>`) => Promise<any> \\| `null`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="remoteQuery"/>
|
|
|
|
___
|
|
|
|
## Methods
|
|
|
|
### withTransaction
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"name":"transactionManager","type":"`EntityManager`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"this","type":"`this`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
|
|
|
|
### shouldRetryTransaction\_
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"name":"err","type":"`Record<string, unknown>` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"work","type":"(`transactionManager`: `EntityManager`) => Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<TResult>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<PricingContext>","optional":false,"defaultValue":"","description":"The pricing context","expandable":false,"children":[]}]} sectionTitle="collectPricingContext"/>
|
|
|
|
### calculateTaxes
|
|
|
|
Gets the prices for a product variant
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"TaxedPricing","type":"`object`","description":"Pricing fields related to taxes.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="calculateTaxes"/>
|
|
|
|
### getProductVariantPricingModulePricing\_
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Map<any, any>>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricingModulePricing_"/>
|
|
|
|
### getProductVariantPricing\_
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Map<string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getProductVariantPricing_"/>
|
|
|
|
### getProductVariantPricing
|
|
|
|
Gets the prices for a product variant.
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"name":"variant","type":"Pick<[ProductVariant](../../entities/classes/entities.ProductVariant.mdx), \"id\" \\| \"product_id\">","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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<object>","optional":false,"defaultValue":"","description":"The product variant prices","expandable":false,"children":[]}]} sectionTitle="getProductVariantsPricing"/>
|
|
|
|
### getProductPricing\_
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Map<string, Record<string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>>>","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
|
|
|
|
<TypeList types={[{"name":"product","type":"Pick<[Product](../../entities/classes/entities.Product.mdx), \"id\" \\| \"variants\">","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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Record<string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Record<string, [ProductVariantPricing](../../medusa/types/medusa.ProductVariantPricing.mdx)>>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]>","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
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<([Product](../../entities/classes/entities.Product.mdx) \\| [PricedProduct](../../medusa/types/medusa.PricedProduct.mdx))[]>","optional":false,"defaultValue":"","description":"A list of products with variants decorated with prices","expandable":false,"children":[]}]} sectionTitle="setProductPrices"/>
|
|
|
|
### getPricingModuleVariantMoneyAmounts
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"name":"variantIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getPricingModuleVariantMoneyAmounts"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<Map<string, [MoneyAmount](../../entities/classes/entities.MoneyAmount.mdx)[]>>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getPricingModuleVariantMoneyAmounts"/>
|
|
|
|
### setAdminVariantPricing
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="setAdminVariantPricing"/>
|
|
|
|
### setAdminProductPricing
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"name":"products","type":"[Product](../../entities/classes/entities.Product.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="setAdminProductPricing"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<([Product](../../entities/classes/entities.Product.mdx) \\| [PricedProduct](../../medusa/types/medusa.PricedProduct.mdx))[]>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="setAdminProductPricing"/>
|
|
|
|
### getShippingOptionPricing
|
|
|
|
Gets the prices for a shipping option.
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)>","optional":false,"defaultValue":"","description":"The shipping option prices","expandable":false,"children":[]}]} sectionTitle="getShippingOptionPricing"/>
|
|
|
|
### setShippingOptionPrices
|
|
|
|
Set additional prices on a list of shipping options.
|
|
|
|
#### Parameters
|
|
|
|
<TypeList types={[{"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<[PriceSelectionContext](../../medusa/interfaces/medusa.PriceSelectionContext.mdx), \"region_id\">","description":"the price selection context to use","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="setShippingOptionPrices"/>
|
|
|
|
#### Returns
|
|
|
|
<TypeList types={[{"name":"Promise","type":"Promise<[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)[]>","optional":false,"defaultValue":"","description":"A list of shipping options with prices","expandable":false,"children":[]}]} sectionTitle="setShippingOptionPrices"/>
|