PricingService
Allows retrieval of prices.
Hierarchy
TransactionBaseService
↳
PricingService
Constructors
constructor
new PricingService(«destructured»
)
Parameters
Name |
---|
«destructured» |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/pricing.ts:62
Properties
__configModule__
Protected
Optional
Readonly
__configModule__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
Protected
Optional
Readonly
__moduleDeclaration__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
featureFlagRouter
Protected
Readonly
featureFlagRouter: FlagRouter
Defined in
medusa/src/services/pricing.ts:58
manager_
Protected
manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
priceSelectionStrategy
Protected
Readonly
priceSelectionStrategy: IPriceSelectionStrategy
Defined in
medusa/src/services/pricing.ts:56
pricingModuleService
Protected
Readonly
pricingModuleService: IPricingModuleService
Defined in
medusa/src/services/pricing.ts:59
productVariantService
Protected
Readonly
productVariantService: ProductVariantService
Defined in
medusa/src/services/pricing.ts:57
regionService
Protected
Readonly
regionService: RegionService
Defined in
medusa/src/services/pricing.ts:54
remoteQuery
Protected
Readonly
remoteQuery: RemoteQueryFunction
Defined in
medusa/src/services/pricing.ts:60
taxProviderService
Protected
Readonly
taxProviderService: TaxProviderService
Defined in
medusa/src/services/pricing.ts:55
transactionManager_
Protected
transactionManager_: undefined
| EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Accessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
-EntityManager
:
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
Name |
---|
TResult |
TError |
Parameters
Name | Description |
---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > |
isolationOrErrorHandler? | IsolationLevel | (error : TError ) => Promise <void | TResult > |
maybeErrorHandlerOrDontFail? | (error : TError ) => Promise <void | TResult > |
Returns
Promise
<TResult
>
-Promise
: the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
calculateTaxes
calculateTaxes(variantPricing
, productRates
): TaxedPricing
Gets the prices for a product variant
Parameters
Name | Description |
---|---|
variantPricing | ProductVariantPricing |
productRates | TaxServiceRate [] |
Returns
TaxedPricing
Defined in
medusa/src/services/pricing.ts:125
collectPricingContext
collectPricingContext(context
): Promise
<PricingContext
>
Collects additional information necessary for completing the price selection.
Parameters
Name | Description |
---|---|
context | PriceSelectionContext |
Returns
Promise
<PricingContext
>
-Promise
: The pricing context
Defined in
medusa/src/services/pricing.ts:89
getPricingModuleVariantMoneyAmounts
Private
getPricingModuleVariantMoneyAmounts(variantIds
): Promise
<Map
<string
, MoneyAmount
[]>>
Parameters
Name |
---|
variantIds |
Returns
Promise
<Map
<string
, MoneyAmount
[]>>
-Promise
:
-Map
:
-string
: (optional)
-MoneyAmount[]
:
Defined in
medusa/src/services/pricing.ts:640
getProductPricing
getProductPricing(product
, context
): Promise
<Record<string
, ProductVariantPricing
>>
Gets all the variant prices for a product. All the product's variants will be fetched.
Parameters
Name | Description |
---|---|
product | Pick <Product , "id" | "variants" > |
context | PriceSelectionContext |
Returns
Promise
<Record<string
, ProductVariantPricing
>>
-Promise
: A map of variant ids to their corresponding prices
-Record
:
-string
: (optional)
Defined in
medusa/src/services/pricing.ts:538
getProductPricingById
getProductPricingById(productId
, context
): Promise
<Record<string
, ProductVariantPricing
>>
Gets all the variant prices for a product by the product id
Parameters
Name | Description |
---|---|
productId | string |
context | PriceSelectionContext |
Returns
Promise
<Record<string
, ProductVariantPricing
>>
-Promise
: A map of variant ids to their corresponding prices
-Record
:
-string
: (optional)
Defined in
medusa/src/services/pricing.ts:556
getProductPricing_
Private
getProductPricing_(data
, context
): Promise
<Map
<string
, Record<string
, ProductVariantPricing
>>>
Parameters
Name |
---|
data |
context |
Returns
Promise
<Map
<string
, Record<string
, ProductVariantPricing
>>>
-Promise
:
-Map
:
-string
: (optional)
-Record
:
Defined in
medusa/src/services/pricing.ts:481
getProductVariantPricing
getProductVariantPricing(variant
, context
): Promise
<ProductVariantPricing
>
Gets the prices for a product variant.
Parameters
Name | Description |
---|---|
variant | Pick <ProductVariant , "id" | "product_id" > |
context | PriceSelectionContext | PricingContext |
Returns
Promise
<ProductVariantPricing
>
-Promise
: The product variant prices
Defined in
medusa/src/services/pricing.ts:335
getProductVariantPricingById
getProductVariantPricingById(variantId
, context
): Promise
<ProductVariantPricing
>
Gets the prices for a product variant by a variant id.
Parameters
Name | Description |
---|---|
variantId | string |
context | PriceSelectionContext | PricingContext |
Returns
Promise
<ProductVariantPricing
>
-Promise
: The product variant prices
Deprecated
Use getProductVariantsPricing instead.
Defined in
medusa/src/services/pricing.ts:384
getProductVariantPricingModulePricing_
Private
getProductVariantPricingModulePricing_(variantPriceData
, context
): Promise
<Map
<any
, any
>>
Parameters
Name |
---|
variantPriceData |
context |
Returns
Promise
<Map
<any
, any
>>
-Promise
:
-Map
:
-any
: (optional)
-any
: (optional)
Defined in
medusa/src/services/pricing.ts:187
getProductVariantPricing_
Private
getProductVariantPricing_(data
, context
): Promise
<Map
<string
, ProductVariantPricing
>>
Parameters
Name |
---|
data |
context |
Returns
Promise
<Map
<string
, ProductVariantPricing
>>
-Promise
:
-Map
:
-string
: (optional)
Defined in
medusa/src/services/pricing.ts:271
getProductVariantsPricing
getProductVariantsPricing(data
, context
): Promise
<{ [variant_id: string]
: ProductVariantPricing
; }>
Gets the prices for a collection of variants.
Parameters
Name | Description |
---|---|
data | { quantity? : number ; variantId : string }[] |
context | PriceSelectionContext | PricingContext |
Returns
Promise
<{ [variant_id: string]
: ProductVariantPricing
; }>
-Promise
: The product variant prices
-object
: (optional)
Defined in
medusa/src/services/pricing.ts:429
getShippingOptionPricing
getShippingOptionPricing(shippingOption
, context
): Promise
<PricedShippingOption
>
Gets the prices for a shipping option.
Parameters
Name | Description |
---|---|
shippingOption | ShippingOption |
context | PriceSelectionContext | PricingContext |
Returns
Promise
<PricedShippingOption
>
-Promise
: The shipping option prices
Defined in
medusa/src/services/pricing.ts:807
setAdminProductPricing
setAdminProductPricing(products
): Promise
<(Product
| PricedProduct
)[]>
Parameters
Name |
---|
products |
Returns
Promise
<(Product
| PricedProduct
)[]>
-Promise
:
-(Product \| PricedProduct)[]
:
-Product \| PricedProduct
: (optional)
Defined in
medusa/src/services/pricing.ts:754
setAdminVariantPricing
setAdminVariantPricing(variants
, context?
): Promise
<PricedVariant
[]>
Parameters
Name |
---|
variants |
context |
Returns
Promise
<PricedVariant
[]>
-Promise
:
-PricedVariant[]
:
Defined in
medusa/src/services/pricing.ts:717
setProductPrices
setProductPrices(products
, context?
): Promise
<(Product
| PricedProduct
)[]>
Set additional prices on a list of products.
Parameters
Name | Description |
---|---|
products | Product [] |
context | PriceSelectionContext |
Returns
Promise
<(Product
| PricedProduct
)[]>
-Promise
: A list of products with variants decorated with prices
-(Product \| PricedProduct)[]
:
-Product \| PricedProduct
: (optional)
Defined in
medusa/src/services/pricing.ts:605
setShippingOptionPrices
setShippingOptionPrices(shippingOptions
, context?
): Promise
<PricedShippingOption
[]>
Set additional prices on a list of shipping options.
Parameters
Name | Description |
---|---|
shippingOptions | ShippingOption [] |
context | Omit <PriceSelectionContext , "region_id" > |
Returns
Promise
<PricedShippingOption
[]>
-Promise
: A list of shipping options with prices
-PricedShippingOption[]
:
Defined in
medusa/src/services/pricing.ts:869
setVariantPrices
setVariantPrices(variants
, context?
): Promise
<PricedVariant
[]>
Set additional prices on a list of product variants.
Parameters
Name | Description |
---|---|
variants | ProductVariant [] |
context | PriceSelectionContext |
Returns
Promise
<PricedVariant
[]>
-Promise
: A list of products with variants decorated with prices
-PricedVariant[]
:
Defined in
medusa/src/services/pricing.ts:578
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name |
---|
err |
Returns
boolean
-boolean
: (optional)
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
withTransaction
withTransaction(transactionManager?
): PricingService
Parameters
Name |
---|
transactionManager? |
Returns
-PricingService
:
Inherited from
TransactionBaseService.withTransaction