calculatePrices - Pricing Module Reference

This documentation provides a reference to the calculatePrices method. This belongs to the Pricing Module.

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead .

This method is used to calculate prices based on the provided filters and context.

Example#

When you calculate prices, you must at least specify the currency code:

Code
1const price = await pricingModuleService.calculatePrices(2  {3    id: ["pset_123", "pset_321"],4  },5  {6    context: {7      currency_code: "usd",8    },9  }10)

To calculate prices for specific minimum and/or maximum quantity:

Code
1const price = await pricingModuleService.calculatePrices(2  {3    id: ["pset_123", "pset_321"],4  },5  {6    context: {7      currency_code: "usd",8      min_quantity: 4,9    },10  }11)

To calculate prices for custom rule types:

Code
1const price = await pricingModuleService.calculatePrices(2  {3    id: ["pset_123", "pset_321"],4  },5  {6    context: {7      currency_code: "usd",8      region_id: "US",9    },10  }11)

Parameters#

The filters to apply on prices.
contextPricingContextOptional
The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value will be retrieved.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<CalculatedPriceSet[]>
The calculated prices matching the context and filters provided.
Was this page helpful?