--- displayed_sidebar: pricingReference badge: variant: orange text: Beta slug: /references/pricing/addPrices sidebar_label: addPrices --- import ParameterTypes from "@site/src/components/ParameterTypes" # addPrices - Pricing Module Reference This documentation provides a reference to the `addPrices` method. This belongs to the Pricing Module. ## addPrices(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)> 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`: ```ts import { initialize as initializePricingModule, } from "@medusajs/pricing" async function addPricesToPriceSet (priceSetId: string) { const pricingService = await initializePricingModule() const priceSet = await pricingService.addPrices({ priceSetId, prices: [ { amount: 500, currency_code: "USD", rules: {}, }, ], }) // do something with the price set or return it } ``` To add prices with rules: ```ts import { initialize as initializePricingModule, } from "@medusajs/pricing" async function addPricesToPriceSet (priceSetId: string) { const pricingService = await initializePricingModule() const priceSet = await pricingService.addPrices({ priceSetId, 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" }, } ], }) // do something with the price set or return it } ``` ### Parameters `", "description": "The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] }, { "name": "sharedContext", "type": "[Context](../../pricing/interfaces/pricing.Context.mdx)", "description": "A context used to share resources, such as transaction manager, between the application and the module.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "enableNestedTransactions", "type": "`boolean`", "description": "A boolean value indicating whether nested transactions are enabled.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "isolationLevel", "type": "`string`", "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "manager", "type": "`TManager`", "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionId", "type": "`string`", "description": "A string indicating the ID of the current transaction.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionManager", "type": "`TManager`", "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] } ]} /> ### Returns ## addPrices(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]> This method adds prices to multiple price sets. ### 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`: ```ts import { initialize as initializePricingModule, } from "@medusajs/pricing" async function addPricesToPriceSet (priceSetId: string) { const pricingService = await initializePricingModule() const priceSets = await pricingService.addPrices([{ priceSetId, prices: [ { amount: 500, currency_code: "USD", rules: {}, }, ], }]) // do something with the price sets or return them } ``` To add prices with rules: ```ts import { initialize as initializePricingModule, } from "@medusajs/pricing" async function addPricesToPriceSet (priceSetId: string) { const pricingService = await initializePricingModule() const priceSets = await pricingService.addPrices([{ priceSetId, 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" }, } ], }]) // do something with the price sets or return them } ``` ### Parameters `", "description": "The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] }, { "name": "sharedContext", "type": "[Context](../../pricing/interfaces/pricing.Context.mdx)", "description": "A context used to share resources, such as transaction manager, between the application and the module.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "enableNestedTransactions", "type": "`boolean`", "description": "A boolean value indicating whether nested transactions are enabled.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "isolationLevel", "type": "`string`", "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "manager", "type": "`TManager`", "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionId", "type": "`string`", "description": "A string indicating the ID of the current transaction.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionManager", "type": "`TManager`", "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] } ]} /> ### Returns