Skip to main content
Skip to main content

PricingService

internal.internal.PricingService

Allows retrieval of prices.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
featureFlagRouterFlagRouterRequired
getPricingModuleVariantMoneyAmountsanyRequired
getProductPricing_anyRequired
getProductVariantPricingModulePricing_anyRequired
getProductVariantPricing_anyRequired
manager_EntityManagerRequired
priceSelectionStrategyIPriceSelectionStrategyRequired
pricingModuleServiceIPricingModuleServiceRequired
productVariantServiceProductVariantServiceRequired
regionServiceRegionServiceRequired
remoteQueryRemoteQueryFunctionRequired
taxProviderServiceTaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited 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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


calculateTaxes

calculateTaxes(variantPricing, productRates): TaxedPricing

Gets the prices for a product variant

Parameters

variantPricingProductVariantPricingRequired
the prices retrieved from a variant
productRatesTaxServiceRate[]Required
the tax rates that the product has applied

Returns

TaxedPricing

TaxedPricingobjectRequired

collectPricingContext

collectPricingContext(context): Promise<PricingContext>

Collects additional information necessary for completing the price selection.

Parameters

contextPriceSelectionContextRequired
the price selection context to use

Returns

Promise<PricingContext>

PromisePromise<PricingContext>Required
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

productPick<Product, "id" | "variants">Required
the product to get pricing for.
contextPriceSelectionContextRequired
the price selection context to use

Returns

Promise<Record<string, ProductVariantPricing>>

PromisePromise<Record<string, ProductVariantPricing>>Required
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

productIdstringRequired
the id of the product to get prices for
contextPriceSelectionContextRequired
the price selection context to use

Returns

Promise<Record<string, ProductVariantPricing>>

PromisePromise<Record<string, ProductVariantPricing>>Required
A map of variant ids to their corresponding prices

getProductVariantPricing

getProductVariantPricing(variant, context): Promise<ProductVariantPricing>

Gets the prices for a product variant.

Parameters

variantPick<ProductVariant, "id" | "product_id">Required
the price selection context to use

Returns

Promise<ProductVariantPricing>

PromisePromise<ProductVariantPricing>Required
The product variant prices

getProductVariantPricingById

getProductVariantPricingById(variantId, context): Promise<ProductVariantPricing>

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

Parameters

variantIdstringRequired
the id of the variant to get prices for
the price selection context to use

Returns

Promise<ProductVariantPricing>

PromisePromise<ProductVariantPricing>Required
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 }[]Required
the price selection context to use

Returns

Promise<{ [variant_id: string]: ProductVariantPricing; }>

PromisePromise<{ [variant_id: string]: ProductVariantPricing; }>Required
The product variant prices

getShippingOptionPricing

getShippingOptionPricing(shippingOption, context): Promise<PricedShippingOption>

Gets the prices for a shipping option.

Parameters

shippingOptionShippingOptionRequired
the shipping option to get prices for
the price selection context to use

Returns

Promise<PricedShippingOption>

PromisePromise<PricedShippingOption>Required
The shipping option prices

setAdminProductPricing

setAdminProductPricing(products): Promise<(Product | PricedProduct)[]>

Parameters

productsProduct[]Required

Returns

Promise<(Product | PricedProduct)[]>

PromisePromise<(Product | PricedProduct)[]>Required

setAdminVariantPricing

setAdminVariantPricing(variants, context?): Promise<PricedVariant[]>

Parameters

variantsProductVariant[]Required

Returns

Promise<PricedVariant[]>

PromisePromise<PricedVariant[]>Required

setProductPrices

setProductPrices(products, context?): Promise<(Product | PricedProduct)[]>

Set additional prices on a list of products.

Parameters

productsProduct[]Required
list of products on which to set additional prices
the price selection context to use

Returns

Promise<(Product | PricedProduct)[]>

PromisePromise<(Product | PricedProduct)[]>Required
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

shippingOptionsShippingOption[]Required
list of shipping options on which to set additional prices
contextOmit<PriceSelectionContext, "region_id">
the price selection context to use

Returns

Promise<PricedShippingOption[]>

PromisePromise<PricedShippingOption[]>Required
A list of shipping options with prices

setVariantPrices

setVariantPrices(variants, context?): Promise<PricedVariant[]>

Set additional prices on a list of product variants.

Parameters

variantsProductVariant[]Required
the price selection context to use

Returns

Promise<PricedVariant[]>

PromisePromise<PricedVariant[]>Required
A list of products with variants decorated with prices

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


withTransaction

withTransaction(transactionManager?): PricingService

Parameters

transactionManagerEntityManager

Returns

PricingService

PricingServicePricingServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?