hi
im trying to get a shopping cart working which has been sourced from http://www.montana.com/ethan/shop.html
however, on the view cart page when i edit the quantities and press recalculate the order button, the quantities do not refresh.
i have used the code exactly as seen, but it wont work and yet the demo works fine!
i've tried emailing the author but with no luck, can anyone help?
here is the code for 'view_cart.php3'. there are two other files which are required which can be found at the above url.
any advice would be really helpful...thanks
PHP Code:<?
mysql_connect(MYSQL_SERVER(),MYSQL_USERNAME(),MYSQL_PASSWORD());
mysql_select_db( "ethan");
include( "shoppingcart.php3");
$table = "shopping";
$cart = new Cart;
if($add)
{
if($ShoppingCart)
$session = $ShoppingCart;
$result = mysql_query( "SELECT * FROM inventory WHERE product='$add'");
$row = mysql_fetch_array($result);
$cart->add_item($table,$session,$row[product],1);
}
if($remove)
{
if($ShoppingCart)
{
$session = $ShoppingCart;
}
$result = mysql_query( "SELECT * FROM inventory WHERE product='$remove'");
$row = mysql_fetch_array($result);
$cart->delete_item($table,$session,$row[product]);
}
if($modify)
{
$contents = $cart->display_contents($table,$session);
for($i = 0; $i < sizeof($quantity); $i++)
{
$oldquan = $contents[quantity][$i];
$product = $contents[product][$i];
$newquan = $quantity[$product];
$cart->modify_quantity($table,$session,$product,$newquan);
}
}
// End update cart
?>
<html>
<head>
<title>Shopping Cart</title>
</head>
<body bgcolor="#FFFFFF" link="#003399" alink="#FF9933" vlink="#996633" text="#000000">
<?
$url = $PHP_SELF;
if(!$ShoppingCard)
$url .= "?session=$session";
echo "<FORM ACTION=$url method=post>\n";
?>
<a name="top"></a>
<img align=left width=171 height=27 alt="Shopping Cart" src="cart.gif">
<br clear=left>
<table align=center border="0" cellpadding="5" cellspacing="0">
<tr valign="top" bgcolor="#CCCC99">
<td width=500 valign="TOP"><font face="Verdana,Helvetica,Arial" size="+2"><b><CENTER>Shopping
Cart Items</b></font></td>
</center>
</TABLE>
<TABLE BORDER=1 cellpadding=2>
<TR>
<TD>Product</TD><TD>Price</TD><TD>Quantity</TD><TD>Total</TD><TD> </TD>
<?
if($ShoppingCart)
{
$session = $ShoppingCart;
}
$contents = $cart->display_contents($table,$session);
if($contents[product][0] != "")
{
$x = 0;
while($x != $cart->num_items($table,$session))
{
echo "<TR><TD>".$contents[product][$x]. "</TD><TD>".$contents[price][$x]. "</TD>\n";
$product = $contents[product][$x];
echo "<TD><INPUT TYPE=text size=3 name=quantity[$product] ";
echo "value=\"".$contents[quantity][$x]. "\"></TD>";
echo "<TD>\$".$contents[total][$x]. "</TD>\n";
echo "<TD><A HREF=\"view_cart.php3?remove=".urlencode($contents[product][$x]);
echo "".(!$ShoppingCart? "&session=$session": ""). "\">Remove</A>";
$x ++;
}
echo "</TD><TR></TABLE>";
echo "<BR><B>Total Order Amount: \$".$cart->cart_total($table,$session). "</B>";
echo "<BR><INPUT TYPE=submit name=modify value=\"Recalculate Order\">";
echo "<BR><BR>";
echo "Back to the <A HREF=\"store.php3".(!$ShoppingCart? "?session=$session": ""). "\">";
echo "Products</A> page";
}
else
echo "There are no items in your shopping cart.";
?>
</FORM>
</BODY>
</HTML>




Bookmarks