setLineItemAdjustments - Cart Module Reference

This documentation provides a reference to the setLineItemAdjustments 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.

This method set the line item adjustments of line items in a cart. The existing line item adjustments, except those included in the specified list, of an item are removed and replaced with the specified adjustments.

Example#

Code
1const lineItemAdjustments =2  await cartModuleService.setLineItemAdjustments("cart_123", [3    {4      id: "adj_123",5      item_id: "caliadj_123",6    },7    {8      item_id: "caliadj_123",9      code: "10%OFF",10      amount: 2000,11    },12    {13      item_id: "caliadj_321",14      code: "50%OFF",15      amount: 3000,16    },17  ])

Parameters#

cartIdstring
The cart's ID.
The line item adjustments to add to the line items. The line item is specified by the item_id field. If the id field is specified, the adjustment is kept in the line item's adjustment and its attributes can be updated.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<LineItemAdjustmentDTO[]>
The added line item adjustments.
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