Skip to main content
Skip to main content

PricingService

Allows retrieval of prices.

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customerService_CustomerServiceRequired
featureFlagRouterFlagRouterRequired
manager_EntityManagerRequired
priceSelectionStrategyIPriceSelectionStrategyRequired
productVariantServiceProductVariantServiceRequired
regionServiceRegionServiceRequired
taxProviderServiceTaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

pricingModuleService

Returns

IPricingModuleServiceobjectRequired

remoteQuery

Returns

RemoteQueryFunctionRemoteQueryFunctionRequired

Methods

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

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

PromisePromise<TResult>Required
the result of the transactional work

calculateTaxes

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

TaxedPricingobjectRequired
Pricing fields related to taxes.

collectPricingContext

Collects additional information necessary for completing the price selection.

Parameters

contextPriceSelectionContextRequired
the price selection context to use

Returns

PromisePromise<PricingContext>Required
The pricing context

getPricingModuleVariantMoneyAmounts

Parameters

variantIdsstring[]Required

Returns

PromisePromise<Map<string, MoneyAmount[]>>Required

getProductPricing

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

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

getProductPricingById

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

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

getProductPricing_

Parameters

dataobject[]Required
contextPricingContextRequired

Returns

PromisePromise<Map<string, Record<string, ProductVariantPricing>>>Required

getProductVariantPricing

Gets the prices for a product variant.

Parameters

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

Returns

PromisePromise<ProductVariantPricing>Required
The product variant prices

getProductVariantPricingById

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

PromisePromise<ProductVariantPricing>Required
The product variant prices

Deprecated

Use getProductVariantsPricing instead.


getProductVariantPricingModulePricing_

Parameters

variantPriceDataobject[]Required
contextPricingContextRequired

Returns

PromisePromise<Map<any, any>>Required

getProductVariantPricing_

Parameters

dataobject[]Required
contextPricingContextRequired

Returns

PromisePromise<Map<string, ProductVariantPricing>>Required

getProductVariantsPricing

Gets the prices for a collection of variants.

Parameters

dataobject[]Required
the price selection context to use

Returns

PromisePromise<object>Required
The product variant prices

getShippingOptionPricing

Gets the prices for a shipping option.

Parameters

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

Returns

PromisePromise<PricedShippingOption>Required
The shipping option prices

setAdminProductPricing

Parameters

productsProduct[]Required

Returns

PromisePromise<(Product | PricedProduct)[]>Required

setAdminVariantPricing

Parameters

variantsProductVariant[]Required
contextPriceSelectionContextRequired

Default: {}

Returns

PromisePromise<PricedVariant[]>Required

setProductPrices

Set additional prices on a list of products.

Parameters

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

Default: {}

Returns

PromisePromise<(Product | PricedProduct)[]>Required
A list of products with variants decorated with prices

setShippingOptionPrices

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">Required
the price selection context to use

Default: {}

Returns

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

setVariantPrices

Set additional prices on a list of product variants.

Parameters

variantsProductVariant[]Required
contextPriceSelectionContextRequired
the price selection context to use

Default: {}

Returns

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

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

withTransaction

Parameters

transactionManagerEntityManager

Returns

PricingServiceobjectRequired
Allows retrieval of prices.
Was this section helpful?