Multiple Add-To-Cart by Qty Field
I've been able to set up a multiple add-to-cart by adding to cart from a recordset lookup, using the check box method. Works, but I'm not happy with it as most people will be ordering with a quantity in mind, rather than in a yes or no sense. Adds an additional step that I want to get rid of ... but I'm stuck. Can't find anything in your support files or in the forums.
I can work out how to do a recordset lookup for all products (there's about 15), but I think my problem is getting the itemQuantity from the posted quantity values lined up with the product. I've tried a couple of variations, but right now the value field is called ATCQty_PRODUCTID (where PRODUCTID represents the ID # for that product).
On adding the item to the cart it calls on $_POST["ATCQty_x"] for the value, which I'm guessing is wrong. I've tried using ATCQty[PRODUCTID] and doing the lookup using that, but I think it's easier to add all products using a quantity of 0 unless it says otherwise ... or am I wrong there too?
Code as follows (just the add to cart part) ...
<?php
// WA eCart Get Info From RS
if (isset($_POST["AddToCartButton_x"]) && isset($totalRows_AddSelected) && $totalRows_AddSelected > 0) {
$Redirect_redirStr="";
do {
$shoppingCart_itemID = floatval("".$row_AddSelected['product_code'] ."");
$shoppingCart_itemName = "".$row_AddSelected['product_title'] ."";
$shoppingCart_itemDescription = "".$row_AddSelected['product_blurb'] ."";
$shoppingCart_itemWeight = floatval("".$row_AddSelected['product_single_weight'] ."");
$shoppingCart_itemQuantity = floatval("".((isset($_POST["ATCQty_x"]))?$_POST["ATCQty_x"]:"") ."");
$shoppingCart_itemPrice = floatval("".$row_AddSelected['product_single_price'] ."");
$shoppingCart_itemDiscExempt = floatval("".$row_AddSelected['product_discount_exempt'] ."");
$shoppingCart->AddToCart(1, "", $shoppingCart_itemID, $shoppingCart_itemName, $shoppingCart_itemDescription, $shoppingCart_itemWeight, $shoppingCart_itemQuantity, $shoppingCart_itemPrice, $shoppingCart_itemDiscExempt);
} while ($row_AddSelected = mysql_fetch_assoc($AddSelected));
if ($Redirect_redirStr != "") {
$shoppingCart->redirStr = $Redirect_redirStr;
}
mysql_data_seek($AddSelected, 0);
$row_AddSelected = mysql_fetch_assoc($AddSelected);
}
?>
... and the part of the form that adds the quantity ...
<input name="ATCQty_<?php echo $row_products['product_id']; ?>" type="text" id="ATCQty_<?php echo $row_products['product_id']; ?>" value="0" size="3" maxlength="2" />
... any help here would be most appreciated.