---
title: "Verify applying and removing a valid coupon recalculates the cart"
description: "Apply a controlled discount, inspect eligibility and arithmetic, then remove it and verify the original payable total and persistent coupon state return."
canonical_url: "https://vostride.com/agent-library/shopping-cart/coupon-apply-remove.md"
md_url: "https://vostride.com/agent-library/shopping-cart/coupon-apply-remove.md"
content_kind: "recipe"
topic: "shopping-cart"
---

# Verify applying and removing a valid coupon recalculates the cart

Apply a controlled discount, inspect eligibility and arithmetic, then remove it and verify the original payable total and persistent coupon state return.

## Risk

Coupon UI can show an accepted code without applying the right base or can leave an invisible discount after removal. The expected amount needs an independent fixture calculation including excluded items and rounding rules.

## Fixtures

- A sandbox cart containing one discount-eligible product and one excluded product.
- A run-owned valid coupon with a known percentage or fixed discount and documented rounding behavior.
- Independent before-and-after totals and a cart hook reporting applied promotion identity and allocations.

## Steps

1. Open the cart and verify both products, their quantities, and the undiscounted total against the fixture expectation.
2. Enter the controlled coupon and apply once; verify an accepted-code indicator and the exact expected discount amount.
3. Inspect line allocations or the cart hook to verify the excluded product receives no discount.
4. Remove the coupon using the visible control and verify the discount row clears and the original total returns.
5. Reload the cart and inspect stored promotion state; verify no applied coupon or residual discount allocation remains.

## Expected results

- The valid coupon applies only to its documented eligible amount.
- The displayed and stored discount allocations reconcile with the independent expected calculation.
- Removing the coupon restores the undiscounted cart durably.

## False-pass traps

- An accepted coupon label does not establish correct discount arithmetic.
- Comparing only grand totals can miss a discount allocated to an excluded item when another line offsets the error.

## Cleanup

- Deactivate the run-owned coupon and clear the fixture cart.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa hooks](/docs/agent-qa/guides/hooks.md)
- [agent-qa auth state](/docs/agent-qa/guides/auth-state.md)

- [Shopping cart QA recipes](/agent-library/shopping-cart.md)
- [Software factory QA library](/agent-library.md)
