Jump to content

Real Numbers *.** instead of Integers?


magicmark

Recommended Posts

Please Please Please help me make this script display a real number as the result without using normal + & - PHP e.g. $Total + $Shipping?

//Variables

$Coupon = '22002';
$Total = 149;
$Shipping = 12.50;

//20% Discount Calculation

$Discount = bcmul($Total, '0.2');
$Discounted = bcsub($Total, $Discount);

//If Statement for Criteria, Compulsory Inputs or Handling

if (empty($Coupon)) {
$TotalWithShipping = bcadd($Total, $Shipping);

} elseif ( $Coupon == '22001' || $Coupon == '22002' ){

$TotalWithShipping = bcadd($Discounted, $Shipping);
} else {
echo "Invalid Coupon Code!";
}

//Display Result

echo $TotalWithShipping;
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.