addRules - Pricing Module Reference
BetaThis documentation provides a reference to the addRules
method. This belongs to the Pricing Module.
addRules(data, sharedContext?): Promise<PriceSetDTO>
This method adds rules to a price set.
Example
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function addRulesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()
const priceSet = await pricingService.addRules({
priceSetId,
rules: [{
attribute: "region_id"
}]
})
// do something with the price set or return it
}
Parameters
The data defining the price set to add the rules to, along with the rules to add.
Returns
The price set that the rules were added to.
addRules(data, sharedContext?): Promise<PriceSetDTO[]>
This method adds rules to multiple price sets.
Example
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function addRulesToPriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()
const priceSets = await pricingService.addRules([{
priceSetId,
rules: [{
attribute: "region_id"
}]
}])
// do something with the price sets or return them
}
Parameters
The data defining the rules to add per price set.
Returns
The list of the price sets that the rules were added to.
Was this section helpful?