|
I have a form with a field for a bonus code that gives you a $20 discount on your order.
if($promocode == 'secretcode') {;
$discount=20;
} else {
$discount=0;
};
Then I just have this to calculate the discount:
$finaltotal = $total - $discount;
So this subtracts 20 from my total but what if I wanted to make the discount 20% of the total instead of a flat $20 discount?
Do I need to create another variable something like:
$percentage = .20;
if($promocode == 'secretcode') {;
$discount= $percentage * $total;
} else {
$discount=0;
};
That didn't work so any tips appreciated.
thanks!!
|