PricingService
internal.internal.PricingService
Allows retrieval of prices.
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>getPricingModuleVariantMoneyAmounts
anyRequiredgetProductPricing_
anyRequiredgetProductVariantPricingModulePricing_
anyRequiredgetProductVariantPricing_
anyRequiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
calculateTaxes
calculateTaxes(variantPricing
, productRates
): TaxedPricing
Gets the prices for a product variant
Parameters
Returns
TaxedPricing
objectRequiredcollectPricingContext
collectPricingContext(context
): Promise
<PricingContext
>
Collects additional information necessary for completing the price selection.
Parameters
Returns
Promise
<PricingContext
>
The pricing context
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
Returns
Promise
<Record<string
, ProductVariantPricing
>>
A map of variant ids to their corresponding prices
getProductPricingById
getProductPricingById(productId
, context
): Promise
<Record<string
, ProductVariantPricing
>>
Gets all the variant prices for a product by the product id
Parameters
productId
stringRequiredReturns
Promise
<Record<string
, ProductVariantPricing
>>
A map of variant ids to their corresponding prices
getProductVariantPricing
getProductVariantPricing(variant
, context
): Promise
<ProductVariantPricing
>
Gets the prices for a product variant.
Parameters
Returns
Promise
<ProductVariantPricing
>
The product variant prices
getProductVariantPricingById
getProductVariantPricingById(variantId
, context
): Promise
<ProductVariantPricing
>
Gets the prices for a product variant by a variant id.
Parameters
variantId
stringRequiredReturns
Promise
<ProductVariantPricing
>
The product variant prices
Deprecated
Use getProductVariantsPricing instead.
getProductVariantsPricing
getProductVariantsPricing(data
, context
): Promise
<{ [variant_id: string]
: ProductVariantPricing
; }>
Gets the prices for a collection of variants.
Parameters
data
{ quantity?: number ; variantId: string }[]RequiredReturns
Promise
<{ [variant_id: string]
: ProductVariantPricing
; }>
The product variant prices
getShippingOptionPricing
getShippingOptionPricing(shippingOption
, context
): Promise
<PricedShippingOption
>
Gets the prices for a shipping option.
Parameters
Returns
Promise
<PricedShippingOption
>
The shipping option prices
setAdminProductPricing
setAdminProductPricing(products
): Promise
<(Product
| PricedProduct
)[]>
Parameters
Returns
Promise
<(Product
| PricedProduct
)[]>
setAdminVariantPricing
setAdminVariantPricing(variants
, context?
): Promise
<PricedVariant
[]>
Parameters
context
PriceSelectionContextReturns
Promise
<PricedVariant
[]>
setProductPrices
setProductPrices(products
, context?
): Promise
<(Product
| PricedProduct
)[]>
Set additional prices on a list of products.
Parameters
context
PriceSelectionContextReturns
Promise
<(Product
| PricedProduct
)[]>
A list of products with variants decorated with prices
setShippingOptionPrices
setShippingOptionPrices(shippingOptions
, context?
): Promise
<PricedShippingOption
[]>
Set additional prices on a list of shipping options.
Parameters
context
Omit<PriceSelectionContext, "region_id">Returns
Promise
<PricedShippingOption
[]>
A list of shipping options with prices
setVariantPrices
setVariantPrices(variants
, context?
): Promise
<PricedVariant
[]>
Set additional prices on a list of product variants.
Parameters
context
PriceSelectionContextReturns
Promise
<PricedVariant
[]>
A list of products with variants decorated with prices
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?
): PricingService
Parameters
transactionManager
EntityManager