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']):"");
}
}
?>