Adding a Promo Code

    The first thing you need to do when introducing a promo code to the form is to add the "Text input" element.

    After that, add the "Code" element with the needed snippet to the very bottom of the form.

    #success, #fail, #promo_field {
    display: block;
    padding: 20px;
    font-size: 20pt;
    font-weight: bold;
    text-align: center;
    #success, #promo_field {background-color: #77f277; color: #000;}
    #fail {background-color: #f74e48; color: #fff;}
    <div id="promo_field" style="display:none;">Promo code: <span id="promo_code"></span></div>

    Now you can add the button that will verify and apply the promo code. To do that, next to the "Text input" add the "Code" element with the following snippet:

    <button class="button-promo"><span>Apply promo code</span></button>

    The final step is to add the script that will process, check and apply the entered promo code as well as calculate the discounted price. Add one more "Code" element to the bottom of the form with the following snippet:

    <span id="success" style="display:none;">Promo code has been successfully applied</span>
    <span id="fail" style="display: none;">Sorry, this promo code doesn’t exist</span>
    var code = {
    name: "promo", // promo code name
    percent: "30%", // discount percentage
    result: 1200 // apply promo code if price is equal to or more than 1200
    $(function() {
    $(".button-promo").click(function() {
    if(RESULTS.db.res[1] < code.result) {
    return false;
    } else {
    $(".button-promo").on("click", function() {
    if($("#input_text-ID").val() === {
    $(".button-promo").attr("disabled", "disabled").css("opacity", ".6");
    $("#input_text-ID").attr("disabled", "disabled").css("opacity", ".6");[0].formula += "-" + code.percent;
    $("#success").slideDown(400, function() {
    } else if($("#input_text-ID").val() !== {

    Where input_text-ID is the ID of your promo code field. To get the ID, right-click on element and choose "Inspect"

    Didn't find the answer? Ask our experts