Skip to main content
Skip to main content

createPriceRules - Pricing Module Reference

Beta

This 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

dataCreatePriceRuleDTO[]Required
The price rules to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<PriceRuleDTO[]>Required
The list of created price rules.
Was this section helpful?