Broadleaf Microservices
  • v1.0.0-latest-prod

Bulk Cart Operations

The following operations allow you to perform bulk operations on customer carts.

Add many items to a cart

Operation

CartClient#addManyItemsToCart(cartId, addItemRequests, options);

Parameters

Parameter Type Required? Description

cartId

string

The id of the cart.

addItemRequests

AddItemRequest[]

A list of item requests to add to the cart.

options

PriceableCartClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example

Example of adding a list of items to a cart
const items = [
  {
    productId: 'product1',
    quantity: 1
  },
  {
    productId: 'product2',
    quantity: 1
  }
];
const cart = await cartClient.addManyItemsToCart('CART_ID', items, { accessToken });

console.log(cart);

Remove many items from a cart

Operation

CartClient#removeManyItemsFromCart(cartId, cartItemIds, options);

Parameters

Parameter Type Required? Description

cartId

string

The id of the cart.

cartItemIds

string[]

The list of the cart item ids to remove.

options

PriceableCartClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example

Example of removing many items from the cart
const itemsIds = ['CART_ITEM_ID_1', 'CART_ITEM_ID_2'];
const cart = await cartClient.removeManyItemsFromCart('CART_ID', itemsIds, { accessToken });

console.log(cart);

Add items from Item Lists to a cart

Operation

CartClient#addItemListsToCart(cartId, itemListIds, options);

Parameters

Parameter Type Required? Description

cartId

string

The id of the cart.

itemListIds

string[]

A list of item list ids to add to the cart.

options

CartClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example

Example of adding items from a list of item list ids to a cart
const itemListIds = [ 'ITEM_LIST_1', 'ITEM_LIST_2' ];
const cart = await cartClient.addItemListsToCart('CART_ID', itemListIds, { accessToken });

console.log(cart);