Im writing something similar to a coupon code function, and want to be able to handle both set amount codes, as well as percentage amounts.
My code is as follows;
$amount = "25"; // amount of discount
$percent = "yes"; // whether coupon is (yes) a percentage, or (no) a flat amount
if($percent == "yes"){
$newprice = ???????; // subtract $amount % of $price, from $price
}else{
$newprice = $price - $amount; // if not a percentage, subtract from price outright
}
Im searching google as you read this looking for a solution but i thought id post it here as well to help others who may encounter same problem.