Skip to main content
Skip to main content

updateLineItems - Cart Module Reference

This documentation provides a reference to the updateLineItems method. This belongs to the Cart Module.

updateLineItems(data): Promise<CartLineItemDTO[]>

This method updates existing line items.

Example

const lineItems = await cartModuleService.updateLineItems([
{
selector: {
id: "cali_123",
},
data: {
quantity: 2,
},
},
{
selector: {
variant_sku: "PANTS",
},
data: {
unit_price: 3000,
},
},
])

Parameters

A list of objects, each holding the filters that specify which items to update, and the attributes to update in the items.

Returns

PromisePromise<CartLineItemDTO[]>Required
The updated line items.

updateLineItems(selector, data, sharedContext?): Promise<CartLineItemDTO[]>

This method updates existing line items matching the specified filters.

Example

const lineItems = await cartModuleService.updateLineItems(
{
variant_sku: "PANTS",
},
{
unit_price: 4000,
}
)

Parameters

selectorPartial<CartLineItemDTO>Required
The filters that specify which line items to update.
dataPartial<UpdateLineItemDTO>Required
The attributes to update in the line items.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CartLineItemDTO[]>Required
The updated line items.

updateLineItems(lineId, data, sharedContext?): Promise<CartLineItemDTO>

This method updates an existing line item.

Example

const lineItem = await cartModuleService.updateLineItems(
"cali_123",
{
unit_price: 3000,
}
)

Parameters

lineIdstringRequired
The line item's ID.
dataPartial<UpdateLineItemDTO>Required
The attributes to update in the line item.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CartLineItemDTO>Required
The updated line item.
Was this section helpful?