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... all + 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 part of 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. Thanks in advance
Here is the processorder code===
Code: Select all
<?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'];
echo '<p>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;
$tax = $totalamount * $taxrate;
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;
echo 'Subtotal: $'.number_format($totalamount,2).'<br />';
$taxrate = 0.15; // local salestax is 15%
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>';
}
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>';