Skip to main content
Skip to main content

PricingService

Allows retrieval of prices.

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

pricingModuleService

Returns

IPricingModuleServiceobjectRequired

remoteQuery

Returns

RemoteQueryFunction(query: string | RemoteJoinerQuery | object, variables?: Record<string, unknown>) => Promise<any> | nullRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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

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

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.

getProductVariantPricingModulePricing_

Parameters

variantPriceDataobject[]Required
contextPricingContextRequired

Returns

PromisePromise<Map<any, any>>Required

getProductVariantPricing_

Parameters

dataobject[]Required
contextPricingContextRequired

Returns

PromisePromise<Map<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.

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

getProductPricing_

Parameters

dataobject[]Required
contextPricingContextRequired

Returns

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

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

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

getPricingModuleVariantMoneyAmounts

Parameters

variantIdsstring[]Required

Returns

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

setAdminVariantPricing

Parameters

variantsProductVariant[]Required
contextPriceSelectionContextRequired

Default: {}

Returns

PromisePromise<PricedVariant[]>Required

setAdminProductPricing

Parameters

productsProduct[]Required

Returns

PromisePromise<(Product | PricedProduct)[]>Required

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

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
Was this section helpful?