Discount
Posted: Sat Jul 28, 2012 11:37 am
Hi Guys,
I want to take 20% off from my price, every thing is working fine, but if the user keep adding the voucher number it keep taking 20% off again, I want it when it take 20% once to not allow again, how can I achieve this?
HTML:
PHP:
Many thanks,
Jo
I want to take 20% off from my price, every thing is working fine, but if the user keep adding the voucher number it keep taking 20% off again, I want it when it take 20% once to not allow again, how can I achieve this?
HTML:
Code: Select all
<form name="form1" action="test1.php" method="post">
<input class="Voucher_TextBox" name="Voucher_TextBox" type="text" value="Voucher Number"/>
<input type="submit" name="CheckVoucher" value="Add Voucher">
</form>
Code: Select all
if (isset($_POST['CheckVoucher']))
{
$Voucher_TextBox = $_POST['Voucher_TextBox'];
if($Voucher_TextBox == 1234)
{
$discount = 0.20; // 20% discount
$price = number_format($price * (1 - $discount), 2); // be sure to have only 2 numbers after the point like: 65.95
$TotalPrice = number_format($price + $shipping, 2); // Get the total price with shipping after the 20% discount.
$total = str_replace('.', '', $TotalPrice); // get rude of the point
$voucherOutput = '20% has been taken off from the item price';
}
else
{
$voucherOutput =
'
<div id="HSBCBuy_Form_Div">
<div class="Dark_Red_Color">The Voucher number you entered is wrong, please insert a correct voucher number.</div>
<div class="Grey_Color">Make sure that you selected the right country from the countries drop list.</div>
</div>
';
}
}
Many thanks,
Jo