createPriceRules - Pricing Module Reference
BetaThis documentation provides a reference to the createPriceRules
method. This belongs to the Pricing Module.
This method is used to create new price rules based on the provided data.
Example
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function createPriceRules (
id: string,
priceSetId: string,
ruleTypeId: string,
value: string,
priceSetMoneyAmountId: string,
priceListId: string
) {
const pricingService = await initializePricingModule()
const priceRules = await pricingService.createPriceRules([
{
id,
price_set_id: priceSetId,
rule_type_id: ruleTypeId,
value,
price_set_money_amount_id: priceSetMoneyAmountId,
price_list_id: priceListId
}
])
// do something with the price rules or return them
}
Parameters
The price rules to create.
Returns
The list of created price rules.
Was this section helpful?