I have a shopping cart I'm working on for a client... Here's the code I added to add canadian tax to the cart...
<tr>
<td align="right" class="normalbold12">HST</td>
<td align="center"> </td>
<td align="left" class="normalbold"><select name="select"
id="selectOpt<?php echo $siteurl?>" class="listbox_cart" onchange="window.location.href='<?php echo
$siteurl?>/cart.php?'+this.options
[this.selectedIndex].value">
<option value="<?php echo $shipvalue13?>">-Select the HST Location-
</option>
<option value="tax1=<?php echo $invoice2?>">Alberta</option>
<option value="tax2=<?php echo $invoice2?>">British
Columbia</option>
<option value="tax3=<?php echo $invoice2?>">Manitoba</option>
<option value="tax4=<?php echo $invoice2?>">New Brunswick</option>
<option value="tax5=<?php echo $invoice2?>">Newfoundland &
Labrador</option>
<option value="tax6=<?php echo $invoice2?>">Nova Scotia</option>
<option value="tax7=<?php echo $invoice2?>">Ontario</option>
<option value="tax8=<?php echo $invoice2?>">Prince Edward
Island</option>
<option value="tax9=<?php echo $invoice2?>">Quebec</option>
<option value="tax10=<?php echo $invoice2?>">Saskatchewan</option>
</select></td>
</tr>
<?php
if($ship3=="")
{ ?>
<tr>
<td align="right" class="normalbold12">HST Rate</td>
<td align="center">:</td>
<?php
if($taxvalue=="")
{
$taxvalue=0;
}
?>
<td align="left" class="normalbold12">$<?php echo $taxvalue?
</td>
<input type="hidden" name="taxrate" value="<?php echo $taxvalue?>" />
</tr>
Now one table cell above it is the EXACT same thing for shipping... Here's it's code...
<tr height="7">
<td ></td>
<td ></td>
<td></td>
</tr>
<tr>
<td> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0"
bgcolor="#EAEAEA">
<tr>
<td width="43%" align="left" valign="top" class="normaltxt">
<?php
if($ship3!="")
{ ?>
*Enter the correct shipping rate from the fregiht calculator. Otherwise
you pay the remaining amount at the time of shipping.
<?php }?>
</td>
<td width="56%"><table width="108%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td align="right" class="normalbold12">Shipping Type</td>
<td align="center"> </td>
<td align="left" class="normalbold"><select name="select"
id="selectOpt<?php echo $siteurl?>" class="listbox_cart" onchange="window.location.href='<?php echo
$siteurl?>/cart.php?'+this.options
[this.selectedIndex].value">
<option value="<?php echo $shipvalue12?>">-Select the Shipping Type-
</option>
<option value="action1=<?php echo $invoice?>">GTA $55.00 </option>
<option value="action2=<?php echo $invoice?>">GTA $85.00 </option>
<option value="action3=<?php echo $invoice?>">Freightquote
calculator</option>
</select></td>
</tr>
<?php
if($ship3=="")
{ ?>
<tr>
<td align="right" class="normalbold12">Shipping Rate</td>
<td align="center">:</td>
<?php
if($shipvalue=="")
{
$shipvalue=0;
}
?>
<td align="left" class="normalbold12">$<?php echo
$shipvalue?></td>
<input type="hidden" name="shiprate" value="<?php echo $shipvalue?>"
/>
</tr>
<?php }?>
<?php
if($ship3!="")
{ ?>
<tr height="5px">
<td align="right" class="normalbold12"></td>
<td align="center"></td>
<td align="left" class="normalbold"></td>
</tr>
<tr>
<td align="right" class="normalbold12">Enter Shipping Rate</td>
<td align="center">:</td>
<td align="left" class="normalbold"><input name="shiprate" type="text"
id="textfield" size="10" value="" /></td>
</tr>
The shipping rate does what it's supposed to do, changes the shipping rate to the appropriate ammount, updates the total, and grand total... When you try and chose the tax rate, it resets everything to 0, including the item in the cart!!
(the variables are defined at the top of the script as so...)
$ship1=$_GET["action1"];
$ship2=$_GET["action2"];
$ship3=$_GET["action3"];
$tax1=$_GET2["tax1"];
$tax2=$_GET2["tax2"];
$tax3=$_GET2["tax3"];
$tax4=$_GET2["tax4"];
$tax5=$_GET2["tax5"];
$tax6=$_GET2["tax6"];
$tax6=$_GET2["tax7"];
$tax6=$_GET2["tax8"];
$tax6=$_GET2["tax9"];
$tax6=$_GET2["tax10"];
if($ship1!="")
{
$shipvalue='55';
$invoice=$ship1;
$ship_type='GTA $55.00';
$shipvalue12='55';
}
if($ship2!="")
{
$shipvalue='85';
$invoice=$ship2;
$ship_type='GTA $85.00';
$shipvalue12='85';
}
if($ship3!="")
{
$invoice=$ship3;
$ship_type='Freightquote calculator';
$shipvalue12='85';
}
if($tax1!="")
{
$taxvalue='55';
$invoice2=$tax1;
$tax_type='Tax1 $55.00';
$shipvalue13='55';
}
if($tax2!="")
{
$taxvalue='65';
$invoice2=$tax2;
$tax_type='tax2 $65.00';
$shipvalue13='65';
}
if($tax3!="")
{
$taxvalue='75';
$invoice2=$tax3;
$tax_type='tax3 $75.00';
$shipvalue13='75';
}
if($tax4!="")
{
$taxvalue='85';
$invoice2=$tax4;
$tax_type='tax4 $85.00';
$shipvalue13='85';
}
if($tax5!="")
{
$taxvalue='95';
$invoice2=$tax5;
$tax_type='tax5 $95.00';
$shipvalue13='95';
}
if($tax6!="")
{
$taxvalue='15';
$invoice2=$tax6;
$tax_type='tax6 $15.00';
$shipvalue13='15';
}
if($tax7!="")
{
$taxvalue='15';
$invoice2=$tax7;
$tax_type='tax7 $15.00';
$shipvalue13='15';
}
if($tax8!="")
{
$taxvalue='15';
$invoice2=$tax8;
$tax_type='tax8 $15.00';
$shipvalue13='15';
}
if($tax9!="")
{
$taxvalue='15';
$invoice2=$tax9;
$ship_type='tax9 $15.00';
$shipvalue13='15';
}
if($tax10!="")
{
$taxvalue='15';
$invoice2=$tax10;
$tax_type='tax10 $15.00';
$shipvalue13='15';
}
Thanks so much for any help. I'd really like to get this project finished for him!
Osyrys