Skip to content
Log in

Apply Voucher Form - Liquid Form Reference

On this page

Usage

```liquid

{% form “apply-voucher” %} {% endform %} ```

Property Value
Form Name apply-voucher
Category Checkout

Form fields

Field name Type Required Description
code Text input Yes The voucher code to apply.
pin Text input No The PIN for a PIN-protected voucher. If the voucher has a PIN and this field is omitted or incorrect, the form will return a validation error and the voucher will not be applied.

Form Object

Inside the form block, you can access the form object which provides:

  • form.errors — Any validation errors after submission

PIN-protected vouchers

If a customer submits a voucher code that requires a PIN, the applied_voucher.state will be requires_pin. Re-render the form with a pin input to let the customer complete the redemption. If the wrong PIN is entered, state will be invalid_pin.

```liquid

{% form “apply-voucher” %} {% if applied_voucher.state == “requires_pin” or applied_voucher.state == “invalid_pin” %} {% if applied_voucher.state == “invalid_pin” %} <p>Incorrect PIN. Please try again.</p> {% endif %} {% endif %} {% endform %} ```

Was this article helpful?

Was this article helpful?