updateLineItems - Cart Module Reference

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

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

updateLineItems(data): Promise<CartLineItemDTO[]>#

This method updates existing line items.

Example#

Code
1const lineItems = await cartModuleService.updateLineItems([2  {3    selector: {4      id: "cali_123",5    },6    data: {7      quantity: 2,8    },9  },10  {11    selector: {12      variant_sku: "PANTS",13    },14    data: {15      unit_price: 3000,16    },17  },18])

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[]>
The updated line items.

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

This method updates existing line items matching the specified filters.

Example#

Code
1const lineItems = await cartModuleService.updateLineItems(2  {3    variant_sku: "PANTS",4  },5  {6    unit_price: 4000,7  }8)

Parameters#

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

Returns#

PromisePromise<CartLineItemDTO[]>
The updated line items.

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

This method updates an existing line item.

Example#

Code
1const lineItem = await cartModuleService.updateLineItems(2  "cali_123",3  {4    unit_price: 3000,5  }6)

Parameters#

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

Returns#

PromisePromise<CartLineItemDTO>
The updated line item.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break