addLineItemAdjustments - Cart Module Reference

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

addLineItemAdjustments(data): Promise<LineItemAdjustmentDTO[]>#

This method adds line item adjustments to line items.

Example#

Code
1const lineItemAdjustments =2  await cartModuleService.addLineItemAdjustments([3    {4      item_id: "caliadj_123",5      code: "50%OFF",6      amount: 3000,7    },8    {9      item_id: "caliadj_321",10      code: "10%OFF",11      amount: 3000,12    },13  ])

Parameters#

The line item adjustments to be created and added to line items. The line item is specified by the item_id field.

Returns#

PromisePromise<LineItemAdjustmentDTO[]>
The added line item adjustments.

addLineItemAdjustments(data): Promise<LineItemAdjustmentDTO[]>#

This method adds a line item adjustment to a line item.

Example#

Code
1const lineItemAdjustments =2  await cartModuleService.addLineItemAdjustments({3    item_id: "caliadj_123",4    code: "50%OFF",5    amount: 3000,6  })

Parameters#

The line item adjustment to be created and added to a line item. The line item is specified by the item_id field.

Returns#

PromisePromise<LineItemAdjustmentDTO[]>
The added line item adjustment.

addLineItemAdjustments(cartId, data): Promise<LineItemAdjustmentDTO[]>#

This method adds line item adjustments to line items in a cart.

Example#

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

Parameters#

cartIdstring
The cart's ID.
The line item adjustments to be created and added to line items. The line item is specified by the item_id field.

Returns#

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