Skip to main content

setCart

Replaces the current user's or guest's cart. Works for an authenticated user or a guest (see Guest mode).

Description​

Replaces the whole cart of the authenticated user, or of a guest identified by the x-guest-id header (see Guest mode), with the items you pass. Resolves to the updated ICartResponse.

.setCart(

);

Parameters schema​

Schema

body(required): ICartSet
New cart contents.
example:

{ items: [{ productId: 1, qty: 2 }] }

body.items(required): ICartItem[]
New contents of the cart.
example:

[{ productId: 1, qty: 2 }]

items.productId(required): number
Product ID.
example: 1

items.qty(required): number
Quantity of the product in the cart.
example: 2

items.addedAt: string
Date and time the item was added, in ISO 8601 format.
example: "2026-05-30T10:00:00.000Z"

Examples​

Minimal example​

const response = await Users.setCart({
items: [{ productId: 2957, qty: 2 }],
});

Example response​

{
"items": [
{
"productId": 2957,
"qty": 2,
"addedAt": "2026-10-27T09:17:04.695Z"
}
],
"total": 1
}

Response schema​

Schema: ICartResponse

items: ICartItem[]
Items in the cart.

items.productId: number
Product ID.
example: 1

items.qty: number
Quantity of the product in the cart.
example: 2

items.addedAt: string
Date and time the item was added, in ISO 8601 format.
example: "2026-05-30T10:00:00.000Z"

total: number
Number of distinct products in the cart, not the sum of qty.
example: 3