Add Coupon Form (tag pair)
add_coupon_form outputs an HTML form that submits a coupon/voucher code to add_coupon_action.
CartThrob form tags output full HTML forms, so do not nest this tag inside another form tag.
If you want coupon input inside checkout submission, add a coupon_code input directly to checkout_form.
See also:
Parameters
This tag has no coupon-specific business parameters.
It supports Global Form Parameters, including return/redirect and validation behavior.
Implementation-backed passthrough form-data parameters include:
actionsecure_returnreturnlanguage
logged_out_redirect is also supported via guarded form-tag behavior.
Variables
This tag parses its body with global CartThrob variables plus form variables (globalVariables(true)).
That includes:
- cart totals and cart context variables
- customer/session variables
custom_data:*variables- form/error variables provided by form builder
See Global Tag Variables.
Conditionals
{if allowed}
Shows content only when the current coupon limit has not been reached.
allowed is set to 0 when both of these are true:
global_coupon_limitis configured.- current applied coupon count is greater than or equal to that limit.
Otherwise, allowed is 1.
{if allowed}
Enter your code here
{/if}
Form Fields
coupon_code
Text input field for the coupon/voucher code.
<input type="text" name="coupon_code" />
Behavior and Constraints
- Submits to
add_coupon_action. - Form validation runs through form builder.
- On validation failure, posted
coupon_codeis preserved and form/error variables are returned. - On success, customer info save flow runs, then CartThrob attempts to apply
coupon_code. - Duplicate coupon codes are not added.
- If
global_coupon_limitis1, adding a new valid code replaces the existing code.
Examples
Basic add-coupon form:
{exp:cartthrob:add_coupon_form return="cart/view_cart"}
<input type="text" name="coupon_code" />
<input type="submit" value="Add" />
{/exp:cartthrob:add_coupon_form}
Show the form only when coupons are allowed:
{exp:cartthrob:add_coupon_form return="cart/view_cart"}
{if allowed}
<input type="text" name="coupon_code" />
<input type="submit" value="Add" />
{if:else}
Coupon limit reached.
{/if}
{/exp:cartthrob:add_coupon_form}
Coupon input inside checkout form (alternative pattern):
{exp:cartthrob:checkout_form return="cart/order_complete"}
<input type="text" name="coupon_code" />
<input type="submit" value="Checkout" />
{/exp:cartthrob:checkout_form}