Apply promo code
apply_promoValidates a promo code provided by the human and attaches it to the cart, returning the updated subtotal, discount, shipping, and total or a clear rejection reason.
Instructions
Validate a promo code the human gave you and attach it to the cart. Returns applied=true with the new subtotal, discount, shipping and total, or applied=false with a reason — an invalid or expired code, or a bundle price in the cart that beats it (codes don't stack with bundle pricing). Codes are case-insensitive and a cart holds one: a valid new code replaces the current one, a rejected one leaves it in place; remove_promo just drops it. Needs at least one item in the cart. Never guess or try codes the human didn't give. The code is re-checked in get_order_preview and prepare_order.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Promo code exactly as the human gave it (case-insensitive). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Normalized promo code (when applied). | |
| error | No | Present when the cart is empty or code is missing. | |
| total | No | ||
| bundle | No | Bundle price that beats the code (when applied=false for that reason). | |
| reason | No | Why the code was rejected (when applied=false). | |
| applied | No | ||
| currency | No | ||
| discount | No | ||
| shipping | No | ||
| subtotal | No |