🖼️
KASKO Frontend Documentation
  • README
  • Getting started
    • Setting up a new webapp
    • Webapp manifest
    • Building the flow
    • Defining layouts
    • Defining computed values
    • Defining dynamic paths
  • Core concepts
    • Forms
    • Validation
      • Using existing validators
      • Adding custom validators
    • Configuration
      • Price format
      • Date format
    • Performing API calls
    • Toggling visibility of components
    • Translations
    • Rules For Robust Application
  • Guides
    • Using logical statements (JsonLogic)
    • Adding discount codes
    • Developing Custom Plugins
    • Setting required requests
    • Adding save quote for later
    • Transforming request data
    • Manifest merging strategy
    • Knockout flow
    • Local pricing logic
    • Setting up dashboard policy profile
    • Handling offers
    • Repeater
  • Snippets
    • Reset input state
  • Useful resources
    • All component descriptions
    • JsonLogic core documentation
    • Kasko.js documentation
    • Example webapp
    • Example plugins (w/ various frameworks)
Powered by GitBook
On this page
  1. Guides

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 1 year ago