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";
}
上面的代码可以正常工作,没有任何问题,但是,如果未应用上述优惠券代码,我会尝试获取它,我希望应用默认价格并加上(+ 8)
这是我尝试过的:
if (discnt < 0) { // only if discount is not active
amt2 = Dollar (amt2 + 8);
des2 = des2 + ", Standard Shipping of $8.00 Applied";
}
答案 0 :(得分:0)
如果优惠券为布尔值,则可以通过这种方式检查是否有条件
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";
}