Add to cart from recordset
I have 3 add to cart buttons on one page. 2 of them were created using add to cart from recordset.
These 2 only allow me to add one item to the cart. If I click add to cart once it adds it to the cart. If I go back to the page and click another item it will not add it to the cart. The redirect takes me to the cart , but only the first item is there.
Here is the code:
<?php
// WA eCart Get Info From RS
if (isset($_POST["WA_Store_Cart_2_ATC"]) && isset($totalRows_rsRelated) && $totalRows_rsRelated > 0) {
$Redirect_redirStr="cart.php";
do {
$WA_Store_Cart_itemID = "".((isset($_POST["addtocart[]"]))?$_POST["addtocart[]"]:"") ."";
$WA_Store_Cart_itemName = "".$row_rsRelated['RelatedItem'] ."";
$WA_Store_Cart_itemDescription = "".$row_rsRelated['short_description'] ."";
$WA_Store_Cart_itemWeight = floatval("0");
$WA_Store_Cart_itemQuantity = floatval("".((isset($_POST["WA_Store_Cart_2_Quantity_Add"]))?$_POST["WA_Store_Cart_2_Quantity_Add"]:"") ."");
$WA_Store_Cart_itemPrice = floatval("".$row_rsRelated['price'] ."");
$WA_Store_Cart_itemThumb = "".$row_WADAProduct_Base['pn'] ."";
$WA_Store_Cart_itemSKU = "".$row_WADAProduct_Base['pn'] ."";
$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_rsRelated = mysql_fetch_assoc($rsRelated));
if ($Redirect_redirStr != "") {
$WA_Store_Cart->redirStr = $Redirect_redirStr;
}
mysql_data_seek($rsRelated, 0);
$row_rsRelated = mysql_fetch_assoc($rsRelated);
}
?>
<?php
// WA eCart Get Info From RS
if (isset($_POST["WA_Store_Cart_3_ATC"]) && isset($totalRows_RelatedModel) && $totalRows_RelatedModel > 0) {
$Redirect_redirStr="cart.php";
do {
$WA_Store_Cart_itemID = "".((isset($_POST["addtocartmodel[]"]))?$_POST["addtocartmodel[]"]:"") ."";
$WA_Store_Cart_itemName = "".$row_RelatedModel['RelatedItem'] ."";
$WA_Store_Cart_itemDescription = "".$row_RelatedModel['medium_description'] ."";
$WA_Store_Cart_itemWeight = floatval("0");
$WA_Store_Cart_itemQuantity = floatval("".((isset($_POST["WA_Store_Cart_3_Quantity_Add"]))?$_POST["WA_Store_Cart_3_Quantity_Add"]:"") ."");
$WA_Store_Cart_itemPrice = floatval("".$row_RelatedModel['price'] ."");
$WA_Store_Cart_itemThumb = "".$row_RelatedModel['thumbnail'] ."";
$WA_Store_Cart_itemSKU = "".$row_rsRelatedModel['pn'] ."";
$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_RelatedModel = mysql_fetch_assoc($RelatedModel));
if ($Redirect_redirStr != "") {
$WA_Store_Cart->redirStr = $Redirect_redirStr;
}
mysql_data_seek($RelatedModel, 0);
$row_RelatedModel = mysql_fetch_assoc($RelatedModel);
}
Can you tell me what I did wrong?