I am writing something similar to the function of a coupon code and I want to be able to process both the set quantity codes and 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 looking for google when you read this looking for a solution, but I thought id would post it here to help others who might run into the same problem.
source share