{"title":"Apply Voucher Form - Liquid Form Reference","slug":"apply-voucher-form-reference","url":"https://support.storeconnect.com/articles/apply-voucher-form-reference","url_markdown":"https://support.storeconnect.com/articles/apply-voucher-form-reference.md","subtitle":null,"summary":"The `apply-voucher` Liquid form redeems a voucher code at checkout, applying the voucher\u0026#39;s value or discount to the current order. Supports optional PIN entry for PIN-protected vouchers.","type":"Developer_Documentation","video_url":"","keywords":"liquid, forms, apply-voucher, checkout, storeconnect","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"## Usage\n\n\n```liquid\n\n{% form \"apply-voucher\" %}\n  \u003c!-- Form fields here --\u003e\n{% endform %}\n```\n\n\n| Property | Value |\n|----------|-------|\n| **Form Name** | `apply-voucher` |\n| **Category** | Checkout |\n\n## Form fields\n\n| Field name | Type | Required | Description |\n|------------|------|----------|-------------|\n| `code` | Text input | Yes | The voucher code to apply. |\n| `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. |\n\n## Form Object\n\nInside the form block, you can access the `form` object which provides:\n\n- `form.errors` — Any validation errors after submission\n\n## PIN-protected vouchers\n\nIf 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`.\n\n\n```liquid\n\n{% form \"apply-voucher\" %}\n  \u003cinput type=\"text\" name=\"code\" value=\"{{ applied_voucher.code }}\"\u003e\n  {% if applied_voucher.state == \"requires_pin\" or applied_voucher.state == \"invalid_pin\" %}\n    \u003cinput type=\"text\" name=\"pin\" placeholder=\"Enter PIN\"\u003e\n    {% if applied_voucher.state == \"invalid_pin\" %}\n      \u003cp\u003eIncorrect PIN. Please try again.\u003c/p\u003e\n    {% endif %}\n  {% endif %}\n  \u003cbutton type=\"submit\"\u003eApply\u003c/button\u003e\n{% endform %}\n```\n"}