Update Item Quantity
updateItemQuantity allows you to update the quantity of an item on an order. The quantity must be greater than 0. Use removeItem if you want to remove an item from an order.
Usage
updateItemQuantity takes in the following object.
interface UpdateItemQuantityRequest {
orderItemId: string;
quantity: number;
}
orderItemIdis theIDof a line item on the order. The order is found on the cart resource, withline_itemson the order being an array of line items. For example, to pick the first line item’s ID on the order you’d useitem.order.line_items.0.id.quantityis the new quantity number you want for your order’s item (e.g.5).
Example
const updateItemQuantityRequest = {
orderItemId: '11ee2722e42886d182fa089e019fd17a',
quantity: 2
};
try {
const response = await sdk.cart.updateItemQuantity(updateItemQuantityRequest);
} catch (error) {
// Handle errors
}
Return Value and Error Handling
updateItemQuantity has the same return value and error handling that is documented for addItem.