close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Multiple Add-To-Cart by Qty Field

Thread began 9/13/2009 6:55 pm by B Tonkin | Last modified 10/02/2009 11:53 am by B Tonkin | 4250 views | 10 replies

B Tonkin

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.

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...