Add to cart
add_to_cartAdds a catalog product to the shopper's cart and returns the updated cart, handling quantity, size, and fabric defaults.
Instructions
Add a catalog product to the user's cart and return the updated cart. good_id comes from a search_products or get_product result; size must be one of get_product's sizes — omit it to use the shopper's saved default from get_user_prefs. Omit fabric to take the first one offered in that size. qty (default 1) is added: if the same product, size and fabric is already in the cart, that line grows (capped at 99) instead of a new line appearing. An unknown good_id or unavailable size returns an error listing the available sizes, and the cart stays unchanged. For an AI-generated print use add_custom_to_cart; to change a line already in the cart, update_cart_item.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| qty | No | Quantity to add (default 1, max 99). | |
| size | No | Size label; must be one of the product's available sizes. Optional when a default size is saved. | |
| fabric | No | Fabric label from get_product, if the product offers a choice. | |
| good_id | Yes | Numeric product id from search_products/get_product. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present instead of a cart when the call failed (bad index, unavailable size, ...). | |
| items | No | Cart lines in index order — this index is what update_cart_item takes. | |
| currency | No | ||
| subtotal | No | Sum of price x qty over all lines, USD. | |
| checkout_url | No | Cart page URL for the human. |