close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Product Price Option Not Getting Added to Shopping Cart

Thread began 5/29/2018 6:13 pm by Robert Crespo | Last modified 5/30/2018 11:38 am by Ray Borduin | 49 views | 2 replies |

Robert Crespo

Product Price Option Not Getting Added to Shopping Cart

I have a problem with the tutorial "Add dynamic product options II (eCommerce Series)
Here is the specific problem I have. I managed to get the product options select list working to the point that the option names and incremental prices are shown. However, when I add the item to the shopping cart only the first option, $4 extra for a potted plant gets added to the cart. The two other options, $6 for a medium pot, and $8 for a large pot do not get added to the shopping cart even if it get's selected. I have spent several hours on this and cannot get the other options to get added to the cart. Here is the code for the select list. Any help you can provide will be greatly appreciated.

<select name="eCart1_2_Potted_Add" id="eCart1_2_Potted_Add">
<option value="<?php echo($rsPotted->getColumnVal("OptionName")); ?>" selected><?php echo($rsPotted->getColumnVal("OptionName")); ?></option>
<?php
while(!$rsPotted->atEnd()) { //dyn select
?>
<option value="<?php echo($rsPotted->getColumnVal("ProductOptionID")); ?>"><?php echo($rsPotted->getColumnVal("OptionName")); ?> + $<?php echo($rsPotted->getColumnVal("OptionPriceIncrement")); ?> </option>
<?php
$rsPotted->moveNext();
} //dyn select
$rsPotted->moveFirst();
?>
</select>

Here is the MySQL recordsets for this page:

<?php
$Recordset1 = new WA_MySQLi_RS("Recordset1",$products,0);
$Recordset1->setQuery("SELECT * FROM products WHERE ProductID = ? ORDER BY ProductID ASC");
$Recordset1->bindParam("i", "".(isset($_GET['ProductID'])?$_GET['ProductID']:"") ."", "-1"); //colname
$Recordset1->execute();
?>
<?php
$rsPotted = new WA_MySQLi_RS("rsPotted",$products,0);
$rsPotted->setQuery("SELECT productoptions.OptionPriceIncrement, productoptions.ProductOptionID, options.OptionName, options.OptionGroupID, optiongroups.OptionGroupName FROM options INNER JOIN productoptions ON options.OptionID = productoptions.OptionID INNER JOIN optiongroups ON options.OptionGroupID = optiongroups.OptionGroupID WHERE optiongroups.OptionGroupName = 'potted' AND productoptions.ProductID = ?");
$rsPotted->bindParam("i", "".($_GET['ProductID']) ."", "-1"); //paramItem
$rsPotted->execute();
?>
<?php
$rsPottedLookup = new WA_MySQLi_RS("rsPottedLookup",$products,0);
$rsPottedLookup->setQuery("SELECT productoptions.OptionPriceIncrement, productoptions.ProductOptionID, options.OptionName, options.OptionGroupID, optiongroups.OptionGroupName FROM options INNER JOIN productoptions ON options.OptionID = productoptions.OptionID INNER JOIN optiongroups ON options.OptionGroupID = optiongroups.OptionGroupID WHERE optiongroups.OptionGroupName = 'potted' AND productoptions.ProductOptionID = ? AND productoptions.ProductID = ?");
$rsPottedLookup->bindParam("i", "".($_POST['eCart1_2_Potted_Add']) ."", "-1"); //paramOption
$rsPottedLookup->bindParam("i", "".($_POST['eCart1_2_ID_Add']) ."", "-1"); //paramItem
$rsPottedLookup->execute();
?>
<?php
// WA eCart MySQLi AddToCart
if (isset($_POST["eCart1_2_ATC"]) || isset($_POST["eCart1_2_ATC_x"])) {
$ATC_itemID = $_POST["eCart1_2_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "cart.php";
$ATC_RedirectIfIn = "";
if (function_exists("rel2abs")) {
$ATC_RedirectIfIn = $ATC_RedirectIfIn?rel2abs($ATC_RedirectIfIn,dirname(__FILE__)):"";
$ATC_RedirectAfter = $ATC_RedirectAfter?rel2abs($ATC_RedirectAfter,dirname(__FILE__)):"";
}
if ("Recordset1" != "") $Recordset1->FindRow("ProductID",$ATC_itemID);
$ATC_itemName = "".($Recordset1->getColumnVal("ProdName")) ."";// column binding
$ATC_itemDescription = "".($Recordset1->getColumnVal("ProdCartDesc")) ."";// column binding
$ATC_itemThumbnail = "".($Recordset1->getColumnVal("ProdThumb")) ."";// column binding
$ATC_itemWeight = floatval("".($Recordset1->getColumnVal("ProdWeight")) ."");// column binding
$ATC_itemQuantity = "".$_POST["eCart1_2_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".($Recordset1->getColumnVal("ProdPrice")) ."");// column binding
$ATC_itemPotted = "".$_POST["eCart1_2_Potted_Add"] ."";// column binding
$ATC_itemPottedPriceInc = floatval("".($rsPotted->getColumnVal("OptionPriceIncrement")) ."");// column binding
if ("Recordset1" != "") $Recordset1->Index = 0;
$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_itemPotted, $ATC_itemPottedPriceInc);
if ($ATC_RedirectAfter != "" && $eCart1->redirStr == "") $eCart1->redirStr = $ATC_RedirectAfter;
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING']?"?".htmlentities($_SERVER['QUERY_STRING']):"");
}
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

Your add to cart should use the recordset: $rsPottedLookup

Instead you are adding from the $Recordset1 recordset.

Sign in to reply to this post

Robert Crespo

I fixed the problem with a really simple solution. I changed the following line in the add to cart button:

$ATC_itemPotted = "".$_POST["eCart1_2_Potted_Add"] ."";// column binding
This adds the price increment based on the select list.

Also, I changed the <option value="<?php echo($rsPotted->getColumnVal("ProductOptionID")); ?>">
to: <option value="<?php echo($rsPotted->getColumnVal("OptionPriceIncrement")); ?>">

This solved the problem that was driving me crazy or hours.

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