> For the complete documentation index, see [llms.txt](https://docs.kasko.io/kasko-frontend-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kasko.io/kasko-frontend-documentation/guides/discount-codes.md).

# Adding discount codes

Before discount codes can be used in the frontend, they must be set-up in the backend. This can be done by reaching out to a KASKO certified backend developer.

## Enabling coupon codes in the frontend

After the discount codes have been enabled for the product, discount codes can be implemented in the frontend. This can be done by following these steps:

Set field definition for `coupon_code`:

```json
{
  "discount": [
    {
      "name": "coupon_code",
      "validation": "string"
    }
  ]
}
```

Add the coupon code component to the flow:

```json
{
  "type": "form-coupon-code",
  "config": {
    "content_key": {
      "input_label": "form.coupon_code.label",
      "input_placeholder": "form.coupon_code.placeholder",
      "button": "form.coupon_code.button"
    }
  }
}
```

Alternatively, this snippet can be used for greater flexibility:

```json
{
  "type": "grid",
  "config": {
    "grid": [
      {
        "class": "col-xs-8",
        "components": [
          {
            "type": "form-input",
            "config": {
              "show_label": true,
              "field_name": "coupon_code"
            }
          }
        ]
      },
      {
        "class": "col-xs-4",
        "components": [
          {
            "type": "form-input-button",
            "config": {
              "type": "button",
              "field_name": "coupon_submit",
              "field_value": true,
              "content_key": "form.coupon_code.button"
            }
          }
        ]
      }
    ]
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kasko.io/kasko-frontend-documentation/guides/discount-codes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
