Skip to main content

Class: PricingService

Allows retrieval of prices.

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    PricingServiceCopy to Clipboard

Constructors

constructor

new PricingService(__namedParametersCopy to Clipboard)

Parameters

NameType
__namedParametersCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/pricing.ts:44

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:10


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:11


featureFlagRouter

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard featureFlagRouter: FlagRouterCopy to Clipboard

Defined in

packages/medusa/src/services/pricing.ts:42


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/pricing.ts:36


priceSelectionStrategy

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard priceSelectionStrategy: IPriceSelectionStrategyCopy to Clipboard

Defined in

packages/medusa/src/services/pricing.ts:40


productVariantService

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productVariantService: ProductVariantServiceCopy to Clipboard

Defined in

packages/medusa/src/services/pricing.ts:41


regionService

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard regionService: RegionServiceCopy to Clipboard

Defined in

packages/medusa/src/services/pricing.ts:38


taxProviderService

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard taxProviderService: TaxProviderServiceCopy to Clipboard

Defined in

packages/medusa/src/services/pricing.ts:39


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/pricing.ts:37

Methods

atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy to Clipboard>

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

Name
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:50


calculateTaxes

calculateTaxes(variantPricingCopy to Clipboard, productRatesCopy to Clipboard): PromiseCopy to Clipboard<TaxedPricingCopy to Clipboard>

Gets the prices for a product variant

Parameters

NameTypeDescription
variantPricingCopy to ClipboardProductVariantPricingCopy to Clipboardthe prices retrieved from a variant
productRatesCopy to ClipboardTaxServiceRateCopy to Clipboard[]the tax rates that the product has applied

Returns

PromiseCopy to Clipboard<TaxedPricingCopy to Clipboard>

The tax related variant prices.

Defined in

packages/medusa/src/services/pricing.ts:105


collectPricingContext

collectPricingContext(contextCopy to Clipboard): PromiseCopy to Clipboard<PricingContextCopy to Clipboard>

Collects additional information neccessary for completing the price selection.

Parameters

NameTypeDescription
contextCopy to ClipboardPriceSelectionContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<PricingContextCopy to Clipboard>

The pricing context

Defined in

packages/medusa/src/services/pricing.ts:69


getProductPricing

getProductPricing(productCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

Gets all the variant prices for a product. All the product's variants will be fetched.

Parameters

NameTypeDescription
productCopy to ClipboardPickCopy to Clipboard<ProductCopy to Clipboard, "id"Copy to Clipboard | "variants"Copy to Clipboard>the product to get pricing for.
contextCopy to ClipboardPriceSelectionContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

A map of variant ids to their corresponding prices

Defined in

packages/medusa/src/services/pricing.ts:389


getProductPricingById

getProductPricingById(productIdCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

Gets all the variant prices for a product by the product id

Parameters

NameTypeDescription
productIdCopy to ClipboardstringCopy to Clipboardthe id of the product to get prices for
contextCopy to ClipboardPriceSelectionContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

A map of variant ids to their corresponding prices

Defined in

packages/medusa/src/services/pricing.ts:407


getProductPricing_

PrivateCopy to Clipboard getProductPricing_(productIdCopy to Clipboard, variantsCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

Parameters

NameType
productIdCopy to ClipboardstringCopy to Clipboard
variantsCopy to ClipboardProductVariantCopy to Clipboard[]
contextCopy to ClipboardPricingContextCopy to Clipboard

Returns

PromiseCopy to Clipboard<RecordCopy to Clipboard<stringCopy to Clipboard, ProductVariantPricingCopy to Clipboard>>

Defined in

packages/medusa/src/services/pricing.ts:351


getProductVariantPricing

getProductVariantPricing(variantCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

Gets the prices for a product variant.

Parameters

NameTypeDescription
variantCopy to ClipboardPickCopy to Clipboard<ProductVariantCopy to Clipboard, "id"Copy to Clipboard | "product_id"Copy to Clipboard>the id of the variant to get prices for
contextCopy to ClipboardPriceSelectionContextCopy to Clipboard | PricingContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

The product variant prices

Defined in

packages/medusa/src/services/pricing.ts:214


getProductVariantPricingById

getProductVariantPricingById(variantIdCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

Gets the prices for a product variant by a variant id.

DeprecatedCopy to Clipboard

Use getProductVariantsPricing instead.

Parameters

NameTypeDescription
variantIdCopy to ClipboardstringCopy to Clipboardthe id of the variant to get prices for
contextCopy to ClipboardPriceSelectionContextCopy to Clipboard | PricingContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

The product variant prices

Defined in

packages/medusa/src/services/pricing.ts:253


getProductVariantPricing_

PrivateCopy to Clipboard getProductVariantPricing_(variantIdCopy to Clipboard, taxRatesCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

Parameters

NameType
variantIdCopy to ClipboardstringCopy to Clipboard
taxRatesCopy to ClipboardTaxServiceRateCopy to Clipboard[]
contextCopy to ClipboardPricingContextCopy to Clipboard

Returns

PromiseCopy to Clipboard<ProductVariantPricingCopy to Clipboard>

Defined in

packages/medusa/src/services/pricing.ts:167


getProductVariantsPricing

getProductVariantsPricing<TCopy to Clipboard, TOutputCopy to Clipboard>(variantIdsCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<TOutputCopy to Clipboard>

Gets the prices for a collection of variants.

Type parameters

NameType
TCopy to ClipboardstringCopy to Clipboard | stringCopy to Clipboard[]
TOutputCopy to ClipboardTCopy to Clipboard extends stringCopy to Clipboard ? ProductVariantPricingCopy to Clipboard : { [variant_id: string]Copy to Clipboard: ProductVariantPricingCopy to Clipboard; }

Parameters

NameTypeDescription
variantIdsCopy to ClipboardTCopy to Clipboardthe id of the variants to get the prices for
contextCopy to ClipboardPriceSelectionContextCopy to Clipboard | PricingContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<TOutputCopy to Clipboard>

The product variant prices

Defined in

packages/medusa/src/services/pricing.ts:294


getShippingOptionPricing

getShippingOptionPricing(shippingOptionCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<PricedShippingOptionCopy to Clipboard>

Gets the prices for a shipping option.

Parameters

NameTypeDescription
shippingOptionCopy to ClipboardShippingOptionCopy to Clipboardthe shipping option to get prices for
contextCopy to ClipboardPriceSelectionContextCopy to Clipboard | PricingContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<PricedShippingOptionCopy to Clipboard>

The shipping option prices

Defined in

packages/medusa/src/services/pricing.ts:493


setProductPrices

setProductPrices(productsCopy to Clipboard, context?Copy to Clipboard): PromiseCopy to Clipboard<(ProductCopy to Clipboard | PricedProductCopy to Clipboard)[]>

Set additional prices on a list of products.

Parameters

NameTypeDescription
productsCopy to ClipboardProductCopy to Clipboard[]list of products on which to set additional prices
contextCopy to ClipboardPriceSelectionContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<(ProductCopy to Clipboard | PricedProductCopy to Clipboard)[]>

A list of products with variants decorated with prices

Defined in

packages/medusa/src/services/pricing.ts:450


setShippingOptionPrices

setShippingOptionPrices(shippingOptionsCopy to Clipboard, context?Copy to Clipboard): PromiseCopy to Clipboard<PricedShippingOptionCopy to Clipboard[]>

Set additional prices on a list of shipping options.

Parameters

NameTypeDescription
shippingOptionsCopy to ClipboardShippingOptionCopy to Clipboard[]list of shipping options on which to set additional prices
contextCopy to ClipboardOmitCopy to Clipboard<PriceSelectionContextCopy to Clipboard, "region_id"Copy to Clipboard>the price selection context to use

Returns

PromiseCopy to Clipboard<PricedShippingOptionCopy to Clipboard[]>

A list of shipping options with prices

Defined in

packages/medusa/src/services/pricing.ts:555


setVariantPrices

setVariantPrices(variantsCopy to Clipboard, contextCopy to Clipboard): PromiseCopy to Clipboard<PricedVariantCopy to Clipboard[]>

Set additional prices on a list of product variants.

Parameters

NameTypeDescription
variantsCopy to ClipboardProductVariantCopy to Clipboard[]list of variants on which to set additional prices
contextCopy to ClipboardPriceSelectionContextCopy to Clipboardthe price selection context to use

Returns

PromiseCopy to Clipboard<PricedVariantCopy to Clipboard[]>

A list of products with variants decorated with prices

Defined in

packages/medusa/src/services/pricing.ts:425


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


withTransaction

withTransaction(transactionManager?Copy to Clipboard): PricingServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

PricingServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:14