Re is out: see what's new Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

Coupons

Updated 3 min read 3 views

The Coupons add-on adds a Coupon field: a promo code with an Apply button. A code takes its discount off the payment or off a Calculator total. Find it under More in the field buttons.

<p>Promo code</p>
[[promo]]

The codes are the field’s settings and stay on your server: the page never has them, so nobody finds them in its source. Each try is checked by the server, a few tries a visitor every ten minutes, so codes can’t be guessed one by one.

Add codes

Click the field’s chip. Under Codes, click Add a code for each one:

ColumnWhat it does
CodeLetters, numbers, – and _, up to 40. Saved in capitals; visitors may type it in any case.
DiscountA percent, such as 10% (up to 100%), or an amount, such as 5.
EndsThe last day it works, in your site’s time zone. Empty: no end.
LimitHow many times it can be used. Empty: no limit.

Under each code you see how many times it was used and how many uses are left. A use counts once a message with the code goes. A code without a discount doesn’t work yet.

The field’s other settings: Placeholder (a hint such as Promo code), Button (Apply by default) and Required.

What visitors see

Visitors type the code and click Apply, or press Enter. The line under the field says what it gives, such as “Code SALE10 applied: 10% off.”, or why it doesn’t work. A code typed and left without Apply is checked too. When the form is sent, the server checks the code again: a wrong, ended or used-up code stops the form with its message.

The texts are in the form’s Messages tab: Coupon applied ({code} and {discount} are filled in), Unknown coupon, Coupon expired, Coupon used up and Too many coupon tries.

Discount on the payment

With a Payment field, nothing more to set: the discount comes off the amount it charges, whether it’s a fixed amount or taken from a field such as a select of plans. A 100% code, or an amount larger than the price, makes the amount 0, and the message goes without a payment.

Discount in a Calculator total

With the Calculator add-on, discount() gives a price less the code’s discount, and the price as it is when there is no code:

discount([subtotal], [promo])

In the formula’s sidebar, Discount of [promo] under Ready-made puts it in for you: select the price first and it goes around it. The total updates as soon as a code is applied.

When a Calculation field uses discount() with the Coupon field, the payment taken from it already has the discount, so the Payment field doesn’t take it off again.

WhatFormula
Plan less the codediscount([plan], [promo])
Discount on the subtotal, then deliverydiscount([subtotal], [promo]) + [delivery]
How much the code saves[subtotal] − discount([subtotal], [promo])

In the rest of the form

  • Rules: a group can show or hide on the Coupon field, such as Promo is not empty.
  • Mail: [promo] prints the code with its discount, SALE10 (10%), [_raw_promo] the code alone.
  • Entries: the code is saved with the entry.

A Coupon field can’t go in a repeated group.

Style it

The field’s look is in templates/fields/coupon/default/style.css of the add-on, loaded with the form’s own style and not when the form takes the theme’s. To change the markup, copy templates/fields/coupon/default/field.php to your-theme/remaily/fields/coupon/default/field.php. Keep the input, and the data-remaily-coupon-* attributes on the button and the line under it.

Was this article helpful?