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:

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

Add the coupon code component to the flow:

{
  "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:

{
  "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"
            }
          }
        ]
      }
    ]
  }
}

Last updated