Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
jquery coupon field not working after changing the addition code

Hi guys im new to coding and im trying to add a coupon code field to my form in contact form 7 in wordpress, the problem I had is that i assigned a value for adult and kid, and depending on the amount of each it would return the total value, but it was returning the value of both adult and kid even if there was only 1 adult and 0 kid, so i found a fix by using this code subtotal = $("#subtotal").val(Number($("#adult").val()*35) + Number($("#kid").val()*18.40)); ,but know the couponcode field does not work, I would really appreciate your help, thanks. This is the link to the form im working on.

The code im using.

jQuery(document).ready(function () {
  //alert("Welcome");
  var adult;
  var kid;
  var subtotal;
  var total;
  var couponcode;

  jQuery("#adult, #kid").on("change", function () {
    adult = this.value;
    kid = this.value;

    subtotal = $("#subtotal").val(
      Number($("#adult").val() * 35) + Number($("#kid").val() * 18.4)
    );
    jQuery("#subtotal").val(subtotal.toFixed(2));
  });

  jQuery('input[name="couponcode"]').on("input keydown keyup", function (e) {
    let couponcode = jQuery('input[name="couponcode"]').val().trim();

    if (couponcode == "CCPPF") {
      total = subtotal * 0.1;
      jQuery("#total").val(total.toFixed(2));
    }
  });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looking at your site reference, which has changed since my previous comment:

enter image description here

The reference to: jQuery("#total"), should be: jQuery("#totcalc")

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!