Skip to main content
Skip to main content

addLineItems - Cart Module Reference

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

addLineItems(data): Promise<CartLineItemDTO[]>

This method adds a line item to a cart

Example

const lineItem = await cartModuleService.addLineItems({
cart_id: "cart_123",
title: "Shirt",
quantity: 2,
unit_price: 4000,
})

Parameters

The line item to create and add to the cart. The cart is specified in the cart_id field.

Returns

PromisePromise<CartLineItemDTO[]>Required
The added line item.

addLineItems(data): Promise<CartLineItemDTO[]>

This method adds line items to carts.

Example

const lineItems = await cartModuleService.addLineItems([
{
cart_id: "cart_123",
title: "Shirt",
quantity: 2,
unit_price: 4000,
},
{
cart_id: "cart_123",
title: "Pants",
quantity: 1,
unit_price: 3000,
},
])

Parameters

The line item to create and add to the carts. The cart is specified in the cart_id field.

Returns

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

addLineItems(cartId, items, sharedContext?): Promise<CartLineItemDTO[]>

This method adds line items to a cart.

Example

const lineItems = await cartModuleService.addLineItems(
"cart_123",
[
{
title: "Shirt",
quantity: 2,
unit_price: 4000,
},
{
title: "Pants",
quantity: 1,
unit_price: 3000,
},
]
)

Parameters

cartIdstringRequired
The cart's ID.
itemsCreateLineItemDTO[]Required
The line items to be created and added.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CartLineItemDTO[]>Required
The added line items.
Was this section helpful?