Continue Shopping with Dynamic pages
I have two links in my nav menu that takes a viewer to the productsbycat.php page with a URL variable that trims the Product list.
If they go to either category page and add a product to the cart, then hit continue shopping, it will return them to the same page. That's all good, but if they then add another product, it replaces the product in the cart with the new product. Add to Cart is in a Repeat Region. Source Code does show the distinct Product ID and it is correct.
Quick fix, I simply changed the Continue Shopping Behaviour to go to a products.php page that does not use a URL variable. Instead, it just shows all products. They can then add product and it behaves correctly.
The troube is, if they go back to the nav menu and pick one of the two category pages and add a product it will wipe out the cart contents again.
Here is the eCart code for the productsbycat.php page.
$param_products = "-1";
if (isset($_GET["Category"])) {
$param_products = (get_magic_quotes_gpc()) ? $_GET["Category"] : addslashes($_GET["Category"]);
}
mysql_select_db($database_zeoconn, $zeoconn);
$query_products = sprintf("SELECT * FROM store_prodcats INNER JOIN store_prods on store_prodcats.Product = store_prods.Name WHERE store_prodcats.Category = %s", GetSQLValueString($param_products, "text"));
$products = mysql_query($query_products, $zeoconn) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);
?>
<?php
// WA eCart AddToCart
if (isset($_POST["eCart1_1_ATC"]) || isset($_POST["eCart1_1_ATC_x"])) {
$ATC_itemID = $_POST["eCart1_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "cart.php";
$ATC_RedirectIfIn = "cart.php";
if (isset($totalRows_products) && $totalRows_products > 0) {
$row_products = WAEC_findRecordMySQL($products, "ID", $ATC_itemID);
if ($row_products) {
$ATC_itemName = "".$row_products['Name'] ."";// column binding
$ATC_itemDescription = "".$row_products['ProdSize'] ."";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = "".$_POST["eCart1_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_products['ProdPrice'] ."");// column binding
mysql_data_seek($products, 0);
$row_products = mysql_fetch_assoc($products);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$eCart1->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice);
if ($ATC_RedirectAfter != "" && $eCart1->redirStr == "") {
$eCart1->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
<?php
// WA eCart Redirect
session_commit();
if ($eCart1->redirStr != "") {
header("Location: ".$eCart1->redirStr);
}
?>