Skip to main content
Skip to main content

upsert - Pricing Module Reference

This documentation provides a reference to the upsert method. This belongs to the Pricing Module.

upsert(data, sharedContext?): Promise<PriceSetDTO[]>

This method updates existing price sets, or creates new ones if they don't exist.

Example

const priceSets = await pricingModuleService.upsert([
{
prices: [
{
amount: 100,
currency_code: "USD",
},
],
},
{
id: "pset_123",
rules: [{ rule_attribute: "region_id" }],
},
])

Parameters

dataUpsertPriceSetDTO[]Required
The attributes to update or create for each price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<PriceSetDTO[]>Required
The updated and created price sets.

upsert(data, sharedContext?): Promise<PriceSetDTO>

This method updates the price set if it exists, or creates a new ones if it doesn't.

Example

const priceSet = await pricingModuleService.upsert({
id: "pset_123",
rules: [{ rule_attribute: "region_id" }],
})

Parameters

dataUpsertPriceSetDTORequired
The attributes to update or create for the new price set.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<PriceSetDTO>Required
The updated or created price set.
Was this section helpful?