I know I'm going to feel relatively dumb when someone points out my error so, thanks in advance.
I am trying to create a simple order entry process. My order entry form is at
It seems to work (with one exception).
When I order a plan and a toolkit the total order is supposed to include the plan price + the toolkit price + the toolkit setup charge (as outlined on the form) and add the tax.
Thus far the php code returns the correct items sold and calculates the order total including tax for the plans and the toolkits and even indicates that the order includes the correct setup charge but the process will not add the appropriate amount for the setup charge to the order.
$totalamount includes all of the variables but I just cannot see what I'm missing.
Any insight will be greatfully appreciated. Once again, thanks in advance
I am trying to create a simple order entry process. My order entry form is at
It seems to work (with one exception).
When I order a plan and a toolkit the total order is supposed to include the plan price + the toolkit price + the toolkit setup charge (as outlined on the form) and add the tax.
Thus far the php code returns the correct items sold and calculates the order total including tax for the plans and the toolkits and even indicates that the order includes the correct setup charge but the process will not add the appropriate amount for the setup charge to the order.
$totalamount includes all of the variables but I just cannot see what I'm missing.
Any insight will be greatfully appreciated. Once again, thanks in advance
Code:
<?php
// create short variable names
$pro = $_POST['pro'];
$comp = $_POST['comp'];
$personal = $_POST['personal'];
$diy = $_POST['diy'];
$host = $_POST['host'];
$qna = $_POST['qna'];
$facts = $_POST['facts'];
$calc = $_POST['calc'];
$news = $_POST['news'];
$setupcomp = $_POST['setupcomp'];
$setuppersonal = $_POST['setuppersonal'];
$setupdiy = $_POST['setupdiy'];
$setuphost = $_POST['setuphost'];
$cust_name = $_POST['cust_name'];
echo '<p>Thank you for your order '.$cust_name.' <br />
Your order is as follows: </p>';
$totalqty = 0;
$totalqty = $pro + $comp + $personal + $diy + $host + $qna + $facts + $calc + $news + $setupcomp + $setuppersonal + $setupdiy + $setuphost;
echo 'Items Ordered: '.$totalqty.'<br />';
$totalamount = 0.00;
define('PROPRICE', 1.00);
define('COMPPRICE', 1.00);
define('PERSONALPRICE', 1.00);
define('DIYPRICE', 1.00);
define('HOSTPRICE', 1.00);
define('QNAPRICE', 1.00);
define('FACTSPRICE', 1.00);
define('CALCPRICE', 1.00);
define('NEWSPRICE', 1.00);
define('SETUPCOMPPRICE', 1.00);
define('SETUPPERSONALPRICE', 1.00);
define('SETUPDIYPRICE', 1.00);
define('SETUPHOSTPRICE', 1.00);
$totalamount = $pro * PROPRICE
+ $comp * COMPPRICE
+ $personal * PERSONALPRICE
+ $diy * DIYPRICE
+ $host * HOSTPRICE
+ $qna * QNAPRICE
+ $facts * FACTSPRICE
+ $calc * CALCPRICE
+ $news * NEWSPRICE
+ $setupcomp * SETUPCOMPPRICE
+ $setuppersonal * SETUPPERSONALPRICE
+ $setupdiy * SETUPDIYPRICE
+ $setuphost * SETUPHOSTPRICE;
echo 'Subtotal: $'.number_format($totalamount,2).'<br />';
$taxrate = 0.15; // local salestax is 15%
$tax = $totalamount * $taxrate;
echo 'Tax: $'.number_format($tax,2).'<br />';
$totalamount = ($totalamount) * (1 + $taxrate);
echo 'Total including tax: $'.number_format ($totalamount,2).'<br />';
if( $totalqty == 0 )
{
echo '<font color=red>';
echo 'You did not order anything! <br />';
echo '</font>';
}
if( $pro + $comp + $personal + $diy + $host> 1 )
{
echo '<font color=red>';
echo 'You may only order one hosting plan! <br /> Please press your browsers back button and select the plan you want <br /> Your order cannot be processed<br />';
echo '</font>';
}
if( $pro + $comp + $personal + $diy + $host == 0 )
{
echo '<font color=red>';
echo 'You must order one hosting plan! <br /> Please press your browsers back button and make a selection <br />Your order cannot be processed<br />';
echo '</font>';
}
if( $comp && ($qna>0||$facts>0||$calc>0||$news>0))
$setupcomp = 1;
if( $personal && ($qna>0||$facts>0||$calc>0||$news>0))
$setuppersonal = 1;
if( $diy && ($qna>0||$facts>0||$calc>0||$news>0))
$setupdiy = 1;
if( $host && ($qna>0||$facts>0||$calc>0||$news>0))
$setuphost = 1;
else
{
if ($pro> 0 )
echo $pro.' Professional Plan<br />';
if ($comp> 0 )
echo $comp.' Comprehensive Plan<br />';
if ($personal> 0 )
echo $personal.' Personal Plan<br />';
if ($diy> 0 )
echo $diy.' DIY Plan<br />';
if ($host> 0 )
echo $host.' Hosting Only Plan<br />';
if ($qna> 0 )
echo $qna.' Quick Q & A ToolKit<br />';
if ($facts> 0 )
echo $facts.' Quick Facts ToolKit<br />';
if ($calc> 0 )
echo $calc.' Calculators ToolKit<br />';
if ($news> 0 )
echo $news.' Quarterly Newsletters ToolKit<br />';
if($pro> 0 && ($qna>0||$facts>0||$calc>0||$news>0))
echo $setupcomp.' Professional Plan ToolKit Setup No Charge<br />';
if ($comp> 0 && ($qna>0||$facts>0||$calc>0||$news>0))
echo $setupcomp.' Comprehensive Plan ToolKit Setup Charge<br />';
if ($personal> 0 && ($qna>0||$facts>0||$calc>0||$news>0))
echo $setuppersonal.' Personal Plan ToolKit Setup Charge<br />';
if ($diy> 0 && ($qna>0||$facts>0||$calc>0||$news>0))
echo $setupdiy.' DIY Plan ToolKit Setup Charge<br />';
if ($host> 0 && ($qna>0||$facts>0||$calc>0||$news>0))
echo $setuphost.' Hosting Only Plan ToolKit Setup Charge<br />';
}
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
?>