close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Multiple Add to Cart

Thread began 6/24/2009 12:30 am by danjen | Last modified 6/29/2009 9:15 am by danjen | 4555 views | 14 replies

danjenBeta Tester

Multiple Add to Cart

I am trying to create multiple add to cart interface where multiple items are added to a cart that have a checkbox.

I have added the add to cart from recordset server behavior and I have created a filter using search wizard to create recordset of the checked items. The problem I am having is that the filter is not working and it is adding everything in the database to the cart.

Here is the filter:
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: AddToCartItems;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if (isset($_POST["WA_Store_Cart_1_ATC_x"])) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparisonFromList("pn","addtocart[]","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_ProductsDetail"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_ProductsDetail"]) && $_SESSION["WADbSearch1_ProductsDetail"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_ProductsDetail"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>

Here is add to cart
<?php
// WA eCart Get Info From RS
if (isset($_POST["WA_Store_Cart_1_ATC_x"]) && isset($totalRows_AddToCartItems) && $totalRows_AddToCartItems > 0) {
$Redirect_redirStr="cart.php";
do {
$WA_Store_Cart_itemID = "".$row_AddToCartItems['pn'] ."";
$WA_Store_Cart_itemName = "".$row_AddToCartItems['medium_description'] ."";
$WA_Store_Cart_itemDescription = "".$row_AddToCartItems['color_code'] ."";
$WA_Store_Cart_itemWeight = floatval("0");
$WA_Store_Cart_itemQuantity = floatval("1");
$WA_Store_Cart_itemPrice = floatval("".$row_AddToCartItems['Price'] ."");
$WA_Store_Cart_itemThumb = "".$row_AddToCartItems['thumbnail'] ."";
$WA_Store_Cart_itemSKU = "".$row_AddToCartItems['brand_name'] ."";

$WA_Store_Cart->AddToCart(1, "", $WA_Store_Cart_itemID, $WA_Store_Cart_itemName, $WA_Store_Cart_itemDescription, $WA_Store_Cart_itemWeight, $WA_Store_Cart_itemQuantity, $WA_Store_Cart_itemPrice, $WA_Store_Cart_itemThumb, $WA_Store_Cart_itemSKU);
} while ($row_AddToCartItems = mysql_fetch_assoc($AddToCartItems));
if ($Redirect_redirStr != "") {
$WA_Store_Cart->redirStr = $Redirect_redirStr;
}
mysql_data_seek($AddToCartItems, 0);
$row_AddToCartItems = mysql_fetch_assoc($AddToCartItems);
}
?>

Here is recordset:

mysql_select_db($database_localhost, $localhost);
$query_AddToCartItems = "SELECT Product_Base.pn, Product_Base.brand_name, Product_Base.color_code, Product_Base.medium_description, Product_Base.thumbnail, Product_Base.Price FROM Product_Base";
setQueryBuilderSource($query_AddToCartItems,$WADbSearch1,false);
$AddToCartItems = mysql_query($query_AddToCartItems, $localhost) or die(mysql_error());
$row_AddToCartItems = mysql_fetch_assoc($AddToCartItems);
$totalRows_AddToCartItems = mysql_num_rows($AddToCartItems);

Here is checkbox:
<td valign="bottom" width="110px"><form name="related"><input type="checkbox" name="addtocart[]" id="addtocart" value="<?php echo $row_rsRelated['AccessoryItem']; ?>" align="top"/><a href="ProductsDetail.php?SKU=<?php echo $row_rsRelated['AccessoryItem']; ?>"><?php echo $row_rsRelated['AccessoryItem']; ?></a><input name="posted" type="hidden" value="1" /></form></td>
<td valign="bottom"><?php echo $row_rsRelated['short_description']; ?></td>
<td valign="bottom" width="120" align="right">$<?php echo $row_rsRelated['price']; ?></td>
<td><form name="WA_Store_Cart_2_ATC_<?php echo $row_rsRelated['AccessoryItem']; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">

Can you tell me what I am doing wrong here?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...