close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Changing Quantity "get" section

Thread began 12/29/2011 12:54 pm by sandy259886 | Last modified 12/30/2011 3:43 pm by sandy259886 | 1093 views | 4 replies |

sandy259886

Changing Quantity "get" section

I have a repeated region with add to cart button on each row of each repeated region section. I have the quantity field named: "quantity_(productID from recordset) I need to update the add to cart server behavior with the correct name for the quantity field.
Specifically, I want to change this row:
$ATC_itemQuantity = "".$_POST["pfgbest_1_Quantity_Add"] ."";// column binding

so that it references the new field name:
quantity_<?php echo $row_rsAssocFormats['PKey']; ?>

HOW DO I DO THAT?

----------------------------------------------------------------------
Below is my repeat region form

<?php do { ?>
<?php
$paramAssocProd_rsAssocFormats = "-1";
if (isset($row_rsAssociation['assocprod'])) {
$paramAssocProd_rsAssocFormats = (get_magic_quotes_gpc()) ? $row_rsAssociation['assocprod'] : addslashes($row_rsAssociation['assocprod']);
}
mysql_select_db($database_traders, $traders);
$query_rsAssocFormats = sprintf("SELECT * FROM prod WHERE PKey = %s", GetSQLValueString($paramAssocProd_rsAssocFormats, "int"));
$rsAssocFormats = mysql_query($query_rsAssocFormats, $traders) or die(mysql_error());
$row_rsAssocFormats = mysql_fetch_assoc($rsAssocFormats);
$totalRows_rsAssocFormats = mysql_num_rows($rsAssocFormats);
?>

<tr>
<td width="300"><?php echo $row_rsAssocFormats['Format']; ?>
</td>
<td width="55"><?php echo $row_rsAssocFormats['PriceCalc']; ?></td>
<td>

<form name="pfgbest_1_ATC_<?php echo $row_rsAssocFormats["PKey"]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<input type="text" name="quantity_<?php echo $row_rsAssocFormats['PKey']; ?>" value="1" size="4" >
<input type="submit" class="eC_FormButton" value="Add to Cart" name="pfgbest_1_ATC">
</form>
</td>
<td></td>
</tr>

<?php } while ($row_rsAssociation = mysql_fetch_assoc($rsAssociation)); ?>

---------------------------------------------------------------------

Below is what the entire add to cart server behavior looks like:

<?php
// WA eCart AddToCart
if (isset($_POST["pfgbest_1_ATC"]) || isset($_POST["pfgbest_1_ATC_x"])) {
$ATC_itemID = $_POST["pfgbest_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "ssl/checkout/shoppingcart.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rsAssocFormats) && $totalRows_rsAssocFormats > 0) {
$row_rsAssocFormats = WAEC_findRecordMySQL($rsAssocFormats, "PKey", $ATC_itemID);
if ($row_rsAssocFormats) {
$ATC_itemName = "".$row_rsAssocFormats['Title'] ."";// column binding
$ATC_itemDescription = "";// column binding
$ATC_itemThumbnail = "";// column binding
$ATC_itemWeight = floatval("".$row_rsAssocFormats['ShipWtFactor'] ."");// column binding
$ATC_itemQuantity = "".$_POST["pfgbest_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rsAssocFormats['PriceCalc'] ."");// column binding
$ATC_itemItemnumber = "".$row_rsAssocFormats['itemNumber'] ."";// column binding
$ATC_itemRetail = floatval("".$row_rsAssocFormats['RetailPrice'] ."");// column binding
$ATC_itemFreeitems = "";// column binding
$ATC_itemBundleitems = "";// column binding
$ATC_itemEbooklink = "".$row_rsAssocFormats['EbookLink'] ."";// column binding
$ATC_itemAllocate = "0";// column binding
$ATC_itemInventoryOnHand = "0";// column binding
$ATC_itemBackorder = "0";// column binding
$ATC_itemapplyDiscount = "0";// column binding
$ATC_itemDiscount = floatval("0");// column binding
$ATC_itemmp3link = "".$row_rsAssocFormats['mp3link'] ."";// column binding
$ATC_itemsendEmail = "".$row_rsAssocFormats['sendEmail'] ."";// column binding
$ATC_itemmediaPage = "".$row_rsAssocFormats['mediaFilePath'] ."";// column binding
$ATC_itemBooksInCart = "".$row_rsAssocFormats['BooksinCart'] ."";// column binding
$ATC_itemDiscountablePrice = floatval("".$row_rsAssocFormats['DiscountablePrice'] ."");// column binding
$ATC_itemItemDiscounts = floatval("0");// column binding
$ATC_itemQualifiedPennyPick = "".$row_rsAffiliates[''] ."";// column binding
mysql_data_seek($rsAssocFormats, 0);
$row_rsAssocFormats = mysql_fetch_assoc($rsAssocFormats);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$pfgbest->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemItemnumber, $ATC_itemRetail, $ATC_itemFreeitems, $ATC_itemBundleitems, $ATC_itemEbooklink, $ATC_itemAllocate, $ATC_itemInventoryOnHand, $ATC_itemBackorder, $ATC_itemapplyDiscount, $ATC_itemDiscount, $ATC_itemmp3link, $ATC_itemsendEmail, $ATC_itemmediaPage, $ATC_itemBooksInCart, $ATC_itemDiscountablePrice, $ATC_itemItemDiscounts, $ATC_itemQualifiedPennyPick);
if ($ATC_RedirectAfter != "" && $pfgbest->redirStr == "") {
$pfgbest->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'];
}
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

since each of the quantity elements and submit buttons are in there own form tags, there is no need to use unique naming for the elements.

When a submit button on your page is pressed, only the quantity element that is inside the same set for <form...>....</form> tags will be sent, you can name each quantity element the same, "pfgbest_1_Quantity_Add", and not worry about changing the name.

Sign in to reply to this post

sandy259886

can't get it to work

The file is live at:

detail.php?PKey=824

When I add one of the items to the cart, I get this message:

Undefined variable: ATC_itemQuantity in /home/tradertest/public_html/detail.php on line 418

I've attached the file for your review.

Attached Files
detail.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the problem is that the recordset you are using for the add to cart button is in the body of the page inside a repeat region, it does not exist when the add to cart button code is running.

create another recordset that that queries the products table, and use that recordset for the bindings in the add to cart button behavior.

Sign in to reply to this post

sandy259886

Duh

Got it fixed. Thanks for the heads up. I apparently had a brain fart.

Sign in to reply to this post

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