Skip to main content
Skip to main content

PricingService

Allows retrieval of prices.

Constructors

constructor

**new PricingService**(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Protected get**activeManager_**(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

pricingModuleService

Protected get**pricingModuleService**(): [IPricingModuleService](/references/services/interfaces/IPricingModuleService)

Returns

IPricingModuleService

addPrices(data: AddPricesDTO, sharedContext?: Context) => Promise<PriceSetDTO>(data: AddPricesDTO[], sharedContext?: Context) => Promise<PriceSetDTO[]>Required
addRules(data: AddRulesDTO, sharedContext?: Context) => Promise<PriceSetDTO>(data: AddRulesDTO[], sharedContext?: Context) => Promise<PriceSetDTO[]>Required
calculatePrices(filters: PricingFilters, context?: PricingContext, sharedContext?: Context) => Promise<CalculatedPriceSetDTO>Required
create(data: CreatePriceSetDTO, sharedContext?: Context) => Promise<PriceSetDTO>(data: CreatePriceSetDTO[], sharedContext?: Context) => Promise<PriceSetDTO[]>Required
createCurrencies(data: CreateCurrencyDTO[], sharedContext?: Context) => Promise<CurrencyDTO[]>Required
createMoneyAmounts(data: CreateMoneyAmountDTO[], sharedContext?: Context) => Promise<MoneyAmountDTO[]>Required
createPriceRules(data: CreatePriceRuleDTO[], sharedContext?: Context) => Promise<PriceRuleDTO[]>Required
createPriceSetMoneyAmountRules(data: CreatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context) => Promise<PriceSetMoneyAmountRulesDTO[]>Required
createRuleTypes(data: CreateRuleTypeDTO[], sharedContext?: Context) => Promise<RuleTypeDTO[]>Required
delete(ids: string[], sharedContext?: Context) => Promise<void>Required
deleteCurrencies(currencyCodes: string[], sharedContext?: Context) => Promise<void>Required
deleteMoneyAmounts(ids: string[], sharedContext?: Context) => Promise<void>Required
deletePriceRules(priceRuleIds: string[], sharedContext?: Context) => Promise<void>Required
deletePriceSetMoneyAmountRules(ids: string[], sharedContext?: Context) => Promise<void>Required
deleteRuleTypes(ruleTypeIds: string[], sharedContext?: Context) => Promise<void>Required
list(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context) => Promise<PriceSetDTO[]>Required
listAndCount(filters?: FilterablePriceSetProps, config?: FindConfig<PriceSetDTO>, sharedContext?: Context) => Promise<[PriceSetDTO[], number]>Required
listAndCountCurrencies(filters?: FilterableCurrencyProps, config?: FindConfig<CurrencyDTO>, sharedContext?: Context) => Promise<[CurrencyDTO[], number]>Required
listAndCountMoneyAmounts(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context) => Promise<[MoneyAmountDTO[], number]>Required
listAndCountPriceRules(filters?: FilterablePriceRuleProps, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context) => Promise<[PriceRuleDTO[], number]>Required
listAndCountPriceSetMoneyAmountRules(filters?: FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PriceSetMoneyAmountRulesDTO>, sharedContext?: Context) => Promise<[PriceSetMoneyAmountRulesDTO[], number]>Required
listAndCountPriceSetMoneyAmounts(filters?: FilterablePriceSetMoneyAmountProps, config?: FindConfig<PriceSetMoneyAmountDTO>, sharedContext?: Context) => Promise<[PriceSetMoneyAmountDTO[], number]>Required
listAndCountRuleTypes(filters?: FilterableRuleTypeProps, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context) => Promise<[RuleTypeDTO[], number]>Required
listCurrencies(filters?: FilterableCurrencyProps, config?: FindConfig<CurrencyDTO>, sharedContext?: Context) => Promise<CurrencyDTO[]>Required
listMoneyAmounts(filters?: FilterableMoneyAmountProps, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context) => Promise<MoneyAmountDTO[]>Required
listPriceRules(filters?: FilterablePriceRuleProps, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context) => Promise<PriceRuleDTO[]>Required
listPriceSetMoneyAmountRules(filters?: FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PriceSetMoneyAmountRulesDTO>, sharedContext?: Context) => Promise<PriceSetMoneyAmountRulesDTO[]>Required
listPriceSetMoneyAmounts(filters?: FilterablePriceSetMoneyAmountProps, config?: FindConfig<PriceSetMoneyAmountDTO>, sharedContext?: Context) => Promise<PriceSetMoneyAmountDTO[]>Required
listRuleTypes(filters?: FilterableRuleTypeProps, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context) => Promise<RuleTypeDTO[]>Required
removeRules(data: RemovePriceSetRulesDTO[], sharedContext?: Context) => Promise<void>Required
retrieve(id: string, config?: FindConfig<PriceSetDTO>, sharedContext?: Context) => Promise<PriceSetDTO>Required
retrieveCurrency(code: string, config?: FindConfig<CurrencyDTO>, sharedContext?: Context) => Promise<CurrencyDTO>Required
retrieveMoneyAmount(id: string, config?: FindConfig<MoneyAmountDTO>, sharedContext?: Context) => Promise<MoneyAmountDTO>Required
retrievePriceRule(id: string, config?: FindConfig<PriceRuleDTO>, sharedContext?: Context) => Promise<PriceRuleDTO>Required
retrievePriceSetMoneyAmountRules(id: string, config?: FindConfig<PriceSetMoneyAmountRulesDTO>, sharedContext?: Context) => Promise<PriceSetMoneyAmountRulesDTO>Required
retrieveRuleType(id: string, config?: FindConfig<RuleTypeDTO>, sharedContext?: Context) => Promise<RuleTypeDTO>Required
updateCurrencies(data: UpdateCurrencyDTO[], sharedContext?: Context) => Promise<CurrencyDTO[]>Required
updateMoneyAmounts(data: UpdateMoneyAmountDTO[], sharedContext?: Context) => Promise<MoneyAmountDTO[]>Required
updatePriceRules(data: UpdatePriceRuleDTO[], sharedContext?: Context) => Promise<PriceRuleDTO[]>Required
updatePriceSetMoneyAmountRules(data: UpdatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context) => Promise<PriceSetMoneyAmountRulesDTO[]>Required
updateRuleTypes(data: UpdateRuleTypeDTO[], sharedContext?: Context) => Promise<RuleTypeDTO[]>Required

remoteQuery

Protected get**remoteQuery**(): [RemoteQueryFunction](/references/services/types/RemoteQueryFunction)

Returns

RemoteQueryFunction

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

Methods

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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

calculateTaxes

**calculateTaxes**(variantPricing, productRates): [TaxedPricing](/references/services/types/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
Pricing fields related to taxes.

collectPricingContext

**collectPricingContext**(context): Promise&#60;[PricingContext](/references/services/types/PricingContext-1)&#62;

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

getPricingModuleVariantMoneyAmounts

Private **getPricingModuleVariantMoneyAmounts**(variantIds): Promise&#60;Map&#60;string, [MoneyAmount](/references/services/classes/MoneyAmount)[]&#62;&#62;

Parameters

variantIdsstring[]Required

Returns

Promise<Map<string, MoneyAmount[]>>

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

getProductPricing

**getProductPricing**(product, context): Promise&#60;Record&#60;string, [ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;&#62;

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&#60;Record&#60;string, [ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;&#62;

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

getProductPricing_

Private **getProductPricing_**(data, context): Promise&#60;Map&#60;string, Record&#60;string, [ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;&#62;&#62;

Parameters

data&#123; productId: string ; variants: [ProductVariant](/references/services/classes/ProductVariant)[] &#125;[]Required
contextPricingContextRequired

Returns

Promise<Map<string, Record<string, ProductVariantPricing>>>

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

getProductVariantPricing

**getProductVariantPricing**(variant, context): Promise&#60;[ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;

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&#60;[ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;

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.


getProductVariantPricingModulePricing_

Private **getProductVariantPricingModulePricing_**(variantPriceData, context): Promise&#60;Map&#60;any, any&#62;&#62;

Parameters

variantPriceData&#123; quantity?: number ; variantId: string &#125;[]Required
contextPricingContextRequired

Returns

Promise<Map<any, any>>

PromisePromise<Map<any, any>>Required

getProductVariantPricing_

Private **getProductVariantPricing_**(data, context): Promise&#60;Map&#60;string, [ProductVariantPricing](/references/services/types/ProductVariantPricing)&#62;&#62;

Parameters

data&#123; quantity?: number ; variantId: string &#125;[]Required
contextPricingContextRequired

Returns

Promise<Map<string, ProductVariantPricing>>

PromisePromise<Map<string, ProductVariantPricing>>Required

getProductVariantsPricing

**getProductVariantsPricing**(data, context): Promise&#60;&#123; [variant_id: string]: [ProductVariantPricing](/references/services/types/ProductVariantPricing); &#125;&#62;

Gets the prices for a collection of variants.

Parameters

data&#123; quantity?: number ; variantId: string &#125;[]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&#60;[PricedShippingOption](/references/services/types/PricedShippingOption)&#62;

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&#60;([Product](/references/services/classes/Product) \| [PricedProduct](/references/services/types/PricedProduct))[]&#62;

Parameters

productsProduct[]Required

Returns

Promise<(Product | PricedProduct)[]>

PromisePromise<(Product | PricedProduct)[]>Required

setAdminVariantPricing

**setAdminVariantPricing**(variants, context?): Promise&#60;[PricedVariant](/references/services/types/PricedVariant)[]&#62;

Parameters

variantsProductVariant[]Required
contextPriceSelectionContextRequired

Default: {}

Returns

Promise<PricedVariant[]>

PromisePromise<PricedVariant[]>Required

setProductPrices

**setProductPrices**(products, context?): Promise&#60;([Product](/references/services/classes/Product) \| [PricedProduct](/references/services/types/PricedProduct))[]&#62;

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

Promise<(Product | PricedProduct)[]>

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

setShippingOptionPrices

**setShippingOptionPrices**(shippingOptions, context?): Promise&#60;[PricedShippingOption](/references/services/types/PricedShippingOption)[]&#62;

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

Promise<PricedShippingOption[]>

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

setVariantPrices

**setVariantPrices**(variants, context?): Promise&#60;[PricedVariant](/references/services/types/PricedVariant)[]&#62;

Set additional prices on a list of product variants.

Parameters

variantsProductVariant[]Required
contextPriceSelectionContextRequired
the price selection context to use

Default: {}

Returns

Promise<PricedVariant[]>

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

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

boolean

booleanboolean

withTransaction

**withTransaction**(transactionManager?): [PricingService](/references/services/classes/PricingService)

Parameters

transactionManagerEntityManager

Returns

PricingService

PricingServicePricingServiceRequired
Was this section helpful?