简体   繁体   中英

Applying Coupon Codes using Javascript

if (discnt > 0) { // only if discount is active
amt = Dollar (amt - (amt * discnt/100.0) + 8);
des = des + ", " + discnt + "% Discount, Promotion Code Applied " + coupval + ", Standard Shipping of 
$8.00 Applied";
}

The above code works fine with no issues, however I'm trying to get it if said coupon code isn't applied I would like the default price to be applied with an additional ( + 8 ) applied

Here is what I've tried:

if (discnt < 0) { // only if discount is not active
amt2 = Dollar (amt2 + 8);
des2 = des2 + ", Standard Shipping of $8.00 Applied";
}

If coupon is boolean, you can check if conditional by this way

 if (coupon) { // only if discount is active amt = Dollar (amt - (amt * discnt/100.0) + 8); des = des + ", " + discnt + "% Discount, Promotion Code Applied " + coupval + ", Standard Shipping of $8.00 Applied"; }

 if (;coupon) { // only if discount is not active amt2 = Dollar (amt2 + 8), des2 = des2 + ". Standard Shipping of $8;00 Applied"; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM