close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Undefined variable: ATC_itemQuantity

Thread begun 8/19/2011 8:45 am by Base5 Designs | Last modified 8/30/2011 8:01 am by Jason Byrnes | 3846 views | 5 replies |

Base5 Designs

Undefined variable: ATC_itemQuantity

Hi I am having a problem with my add to cart buttons

Notice: Undefined variable: ATC_itemQuantity in /albionwineshippers.co.uk\httpdocs\startlist.php on line 137

i dont understand why its not getting set, as in firebug it shows the correct ID being posted along with the quantity:

Posted Vars from firebug are:
eCart1_1_ATC Add to Cart
eCart1_1_ATC.x 43
eCart1_1_ATC.y 17
eCart1_1_ID_Add 53
eCart1_1_Quantity_Add 1


I have attached the php file in a zip, the page can be viewed at:
albion.base5.eu (its on an index page and included using framework

the standalone page is here:
startlist.php

here is the code generated by ecart:

<?php
// WA eCart AddToCart
if (isset($_POST["eCart1_1_ATC"]) || isset($_POST["eCart1_1_ATC_x"])) {
$ATC_itemID = $_POST["eCart1_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rs_products) && $totalRows_rs_products > 0) {
$row_rs_products = WAEC_findRecordMySQL($rs_products, "id_prd", $ATC_itemID);
if ($row_rs_products) {
$ATC_itemName = "".$row_rs_products['name_prd'] ."";// column binding
$ATC_itemDescription = "".$row_rs_products['shortdesc_prd'] ."";// column binding
$ATC_itemThumbnail = "".$row_rs_products['image_prd'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rs_products['weight_prd'] ."");// column binding
$ATC_itemQuantity = "".$_POST["eCart1_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rs_products['price_prd'] ."");// column binding
$ATC_itemBottles = floatval("".$row_rs_products['bottles_prd'] ."");// column binding
$ATC_itemOnSale = "".$row_rs_products['onsale_prd'] ."";// column binding
$ATC_itemSalePrice = floatval("".$row_rs_products['saleprice_prd'] ."");// column binding
mysql_data_seek($rs_products, 0);
$row_rs_products = mysql_fetch_assoc($rs_products);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$eCart1->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemBottles, $ATC_itemOnSale, $ATC_itemSalePrice);
if ($ATC_RedirectAfter != "" && $eCart1->redirStr == "") {
$eCart1->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'];
}
}
}
?>
<?php
// WA eCart Redirect
if ($eCart1->redirStr != "") {
session_commit();
header("Location: ".$eCart1->redirStr);
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

that happens when the recordset used for the add to cart button is empty, or does not contain the correct record for the item being added.

in your case, it is because the add to cart recordset does not contain the item being added because you are using both rand() and limiting to 2 records.


It's fine to do that on the recordset that is used to populate the page, but the recordset used by the add to cart button will need to return all products so that it can lookup the one being added.

Sign in to reply to this post

Base5 Designs

Thanks Jason that explains things nicely.

I've created a new unfiltered recordset (rs_cartdata) for the cart, and the product is adding to the cart correctly now but with a new problem.

whatever quantity is added when i go to the cart view the quantity is double.

i have worked out that this is being caused by, the banner that loads in (which also has an ecart add to button on it.

the banner like the list page is a standalone page that gets loaded in dynamically using the webassist framework.

i figure its adding it twice because the code is on the page twice once in the banner and once on the list page, later i plan to have widgets where a product can also be added which will add yet another set add to cart button code.

whats the best way forward in this scenario?

1) creating the add to cart and then renaming each one to a different value so on the index page it would be eCart1_1_....
on the banner page eCart1_2....
on the widget eCart1_3....

that i figure will work but i think i would also need different recordsets for the different cart instances rs_cartdata1, rs_cartdata2 etc

this seems very code heavy and difficult to keep track of having so many recordsets that are basicallyt the same.

2) is it possible to have all the code on the main index framework page and then just the add to cart forms on the plugin pages?
if so whats the best way about doing this or do you perhaps have another idea that would work?

thanks for your time once again.

Sign in to reply to this post

Jason ByrnesWebAssist

It's adding multiple items because the add to cart code is inside the loop for the rs_drinkcat recordsset. Since the code is inside that recordset loop, it will be repeated for each record in the rs_drinkcat recordset.



You could have the add to cart behavior code on the indix page and reyuse the add to cart button code on your page.


as long as the hidden element for the ID:
<input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_rs_products["id_prd"]; ?>" >

is passing the correct ID for the product that should be added to the cart from that any particular widget page, it will work fine.

Sign in to reply to this post

Base5 Designs

Hi Jason

I am still a little stuck with this.

as i mentioend i have a framework page which loads in various items.

the order the items are loaded in (due to the layout of the template) as follows:

my cart widget (in the top left of the page within my banner)
my site menu (css menu writer menu)
my special offers Banner (showing random products from the DB just above my main content)
my page content (on the left colulm of my main content
my other widgets (on the right colulmn of my main content)
my footer (at the base of the page)

the items are getting added to the cart, but the cart widget does not update unless the page is refreshed.

i am assuming this is because he cart widget is loaded in before the add to cart code has run or something.

where do i need to place the add to cart code?

can i just add it to the cart widget (as thats gets loaded in on every page on the site)
can i just add it on my index page (the framework template page that loads all the other stuff in)

or do i need to add it to all the pages that are loaded in, that use the cart content/add an item to the cart.

or is there something else i can do to ensure that the cart widget reflects the correct number of items in the cart, once an item has been added, without having to refresh.

i appreciate your time once again :)

Sign in to reply to this post

Jason ByrnesWebAssist

I would add the add to cart code to the index page, it would probably work if you added it to the cart widget page, but you may need to play with the code order.

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