Overview
Henry’s Universal Cart helpers let you manage a shopping cart for each shopper. Pass results from Product Discovery or bring your own product links, and Henry persists carts, quantities, variant checks, and totals for you.Prerequisites
- Henry API key (sandbox or production)
@henrylabs/sdkinstalled on your server- Stable
x-user-idvalue that uniquely identifies the shopper in your system
1
Add or update items
Use The response returns
client.cart.items.add to append new products or adjust quantities. Pass the shopper identifier via the x-user-id request option.added_products, updated_products, and a cart_summary with totals. When checkVariantAvailability is true, Henry starts variant checks and surfaces their IDs in data.variant_checks.2
List cart contents
Fetch the current cart to render a mini-cart or checkout summary.Each product echoes the metadata you supplied plus computed totals.
3
Remove individual products
When a shopper deletes a line item, call
client.cart.items.remove. The productId must match the identifier you originally supplied.4
Clear the cart
Reset the cart entirely (for example, on logout) with The response confirms the cart is empty. Henry also clears carts automatically after a successful checkout.
client.cart.items.clear.Reuse the same
x-user-id in downstream checkout calls so Henry can hydrate
the cart automatically when you initiate a hosted or headless session.Troubleshooting
400 Bad Request– validate price formatting (strings) and ensure the quantity is greater than zero.404 Cart already empty– surfaced when clearing an empty cart; you can safely ignore it for idempotent flows.- Variant checks return IDs in
data.variant_checks; poll them withclient.products.variantCheck.retrieveStatusfor a definitive in-stock answer.

