addPrices - Pricing Module Reference
This documentation provides a reference to the addPrices
method. This belongs to the Pricing Module.
addPrices(data, sharedContext?): Promise<PriceSetDTO>
This method adds prices to a price set.
Example
To add a default price to a price set, don't pass it any rules and make sure to pass it the currency_code
:
To add prices with rules:
const priceSet = await pricingModuleService.addPrices({
priceSetId: "pset_123",
prices: [
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow",
},
},
{
amount: 400,
currency_code: "EUR",
min_quantity: 0,
max_quantity: 4,
rules: {
region_id: "PL",
},
},
{
amount: 450,
currency_code: "EUR",
rules: {
city: "krakow",
},
},
],
})
Parameters
The data defining the price set to add the prices to, along with the prices to add.
Returns
The price set that the prices were added to.
addPrices(data, sharedContext?): Promise<PriceSetDTO[]>
This method adds prices to multiple price sets.
Example
const priceSets = await pricingModuleService.addPrices([
{
priceSetId: "pset_123",
prices: [
// default price because it doesn't
// have rules
{
amount: 500,
currency_code: "USD",
rules: {},
},
],
},
{
priceSetId: "pset_321",
prices: [
// prices with rules
{
amount: 300,
currency_code: "EUR",
rules: {
region_id: "PL",
city: "krakow",
},
},
],
},
])
Parameters
The data defining the prices to add per price set.
Returns
The list of the price sets that prices were added to.
Was this section helpful?