Remove Item

removeItem allows you to remove a line item from an order.

Usage

removeItem takes in the following object.

interface UpdateItemQuantityRequest {
    orderItemId: string;
    orderId?: string;
}
  • orderItemId is the ID of a line item on the order. The order is found on the cart resource, with line_items on the order being an array of line items. For example, to pick the first line item’s ID on the order you’d use item.order.line_items.0.id.
  • orderId is the ID of the order you’re updating. Only needed if you’re managing multiple orders. Otherwise exclude the field, and the SDK will use the existing order from your cookies.

Example

const removeItemRequest = {
    orderItemId: '11ee2722e42886d182fa089e019fd17a',
};
try {
    const response = await sdk.cart.removeItem(removeItemRequest);
} catch (error) {
    // Handle errors
}

Return Value and Error Handling

removeItem has the same return value and error handling that is covered in addItem.