shopping cart help
Posted: Fri Nov 05, 2004 3:08 pm
I have been hacking at this shopping cart and I am trying to get it to calculate the shipping charges.
If there is anyone out there that can help me out with this..I am still a newbie at php.
Here is what I have so far:
I have a field to take the weight of each product and I have written the code to calculate the shipping charge for one product, but I have not been able to add all the weights up and then calculate the shipping.
Here is the code for the view shopping cart portion were I think I should insert the weight of each product.
I have a limited budget, but would not mind paying someone to help me out with this.[/php_man]
If there is anyone out there that can help me out with this..I am still a newbie at php.
Here is what I have so far:
I have a field to take the weight of each product and I have written the code to calculate the shipping charge for one product, but I have not been able to add all the weights up and then calculate the shipping.
Here is the code for the view shopping cart portion were I think I should insert the weight of each product.
Code: Select all
<?php
<script language="JavaScript">
<!--
function confirmMsg(msg){
if(!confirm(msg)){
return false;
} else {
return true;
}
}
//-->
</script>
<link href="../css/general.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
@import url(../css/styles.css);
-->
</style>
<table width="768" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><?php if($result[count]>0){ ?>
<form action="<?php print $PHP_SELF; ?>" method="post">
<input type="hidden" name="m" value="modify">
<table width=100% border=0 align="center" cellpadding=2 cellspacing=0>
<tr>
<td colspan=6><font face="verdana,arial,helvetica" size=4> View Shopping Cart</font> <br>
<br>
</td>
</tr>
<tr>
<td bgcolor="#F2F0F0"><font face="arial,verdana,helvetica" size=2> <b>Qty.</b></font> </td>
<td bgcolor="#F2F0F0"><font face="arial,verdana,helvetica" size=2> <b>SKU</b></font> </td>
<td bgcolor="#F2F0F0"><font face="arial,verdana,helvetica" size=2> <b>Item Name</b></font> </td>
<td bgcolor="#F2F0F0"><font face="arial,verdana,helvetica" size=2> <b>Price</b></font> </td>
<td bgcolor="#F2F0F0"><font face="arial,verdana,helvetica" size=2> <b>Subtotal</b></font> </td>
<td bgcolor="#F2F0F0" align="center"><font face="arial,verdana,helvetica" size=2> <b>Delete</b></font> </td>
</tr>
<?php
$x = 0;
while($list = mysql_fetch_array($result[result])){
$bgcolor = ($x%2)?"#EEEFF8":"#FFFFFF";
$list[pOption] = stripslashes($list[pOption]);
$list[pName] = stripslashes($list[pName]);
$qty = ($list[pQty]+$qty);
$subtotal = ($list[subTotal]+$subtotal);
?>
<tr>
<td valign="top"><input type="text" name="pQty[<?php print $x ?>]" size=1 maxlength=3 value="<?php print $list[pQty]; ?>">
<input type="hidden" name="cID[<?php print $x ?>]" size=3 maxlength=3 value="<?php print $list[cID]; ?>">
</td>
<td valign="top"><font face="arial,verdana,helvetica" size=2>
<?php $list[pNum] ? print $list[pNum] : print " "; ?>
</font></td>
<td valign="top"><font face="arial,verdana,helvetica" size=2> <?php print $list[pName]; ?><br>
<?php $list[pOption] ? print " ($list[pOption])" : ""; ?>
</font> </td>
<td valign="top"><font face="arial,verdana,helvetica" size=2> $<?php print number_format($list[pPrice], 2); ?></font>
</td>
<td valign="top"><font face="arial,verdana,helvetica" size=2> $<?php print number_format($list[subTotal], 2); ?></font> </td>
<td align="center" valign="top"><a onClick="javascript:return confirmMsg('Are You Sure You Want to Remove the ''''<?php print $list[pQty]." ".$db->stripIt($list[pName]); $list[pOption] ? print " (".$db->stripIt($list[pOption]).")" : ""; ?>'''' From Your Shopping Cart?');" href="<?php print $PHP_SELF; ?>?m=remove&cID=<?php print $list[cID]; ?>" onMouseOver="javascript:window.status=''; return true;"><img src="images/delete.gif" width=14 height=16 alt="Remove the ''<?php print $list[pQty]." ".$db->stripIt($list[pName]); $list[pOption] ? print " (".$db->stripIt($list[pOption]).")" : ""; ?>'' From Your Shopping Cart" border=0></a><br>
</td>
</tr>
<tr>
<td colspan=6><img src="images/hr.gif" width=424 height=3 border=0><br>
</td>
</tr>
<?php
$x++;
}
?>
</table>
<table width=100% border=0 align="center" cellpadding=2 cellspacing=0>
<tr>
<td><font face="arial,verdana,helvetica" size=2> <b><?php print $qty; ?></b> item(s) in cart</font> </td>
<td align="right"><font face="arial,verdana,helvetica" size=2> Subtotal: <b>$<?php print number_format($subtotal, 2); ?></b></font><br>
</td>
</tr>
<tr align="left">
<td colspan=2><br>
<br>
<input type="image" src="images/update_cart_btn.gif" width=102 height=27 alt="UPDATE CART" border=0> <a href="<?php print $PHP_SELF."?m=empty" ?>" onClick="javascript:return confirmMsg('Are You Sure You Want to Empty the <?php $qty==1 ? print "1 Item" : print "$qty Items"; ?> From Your Shopping Cart?');" onMouseOver="javascript:window.status=''; return true;"><img src="images/empty_cart_btn.gif" width=95 height=27 alt="EMPTY CART" border=0></a><img src="../images/spacer.gif" width=3 height=3 border=0><a href="products/cookware_calderos.php"><img src="images/continue_shopping_btn.gif" width=151 height=27 alt="CONTINUE SHOPPING" border=0></a><img src="../images/spacer.gif" width=3 height=3 border=0><a href="<?php print $PHP_SELF; ?>?m=checkout" onMouseOver="javascript:window.status=''; return true;"><img src="images/check_out_btn.gif" width=91 height=27 alt="CHECK OUT" border=0></a><br>
</td>
</tr>
</table>
<?php } else { ?>
<table width=100% border=0 align="center" cellpadding=2 cellspacing=0>
<tr>
<td><font face="arial,verdana,helvetica" size=4> View Shopping Cart </font> <br>
<br>
</td>
</tr>
<tr>
<td><font face="arial,verdana,helvetica" size=2> There are <b>no</b> items in your shopping cart.<br>
<br>
<a href="products/cookware_calderos.php" class="link">View Products</a> </font> </td>
</tr>
</table></form>
<?php } ?>
</td>
</tr>
</table>
?>I have a limited budget, but would not mind paying someone to help me out with this.[/php_man]