Carrying over a parent ID value and problmes with parent ID in general...
We have parent ID products listed on category pages on our website which, when selected, take users to a product detail page which they MUST make choices/selections on in order to proceed. When the choices are made (drop-down menus) the page updates using an onchange event so that the correct product code and, if applicable, price are updated and the customer can then add to cart. Great!
However, there are two issues with this...
Issue 1
The parent product has, like the actual products, colour (Multiple Options), dimmable (Yes/No) and sensor (Yes/No) fields which need to contain data. On the parent product pages (category pages) we are displaying a graphic for each of these values depending on what those values are so we need to use them to show, for example, whether or not a product is dimmable.
Here is an example. This is the parent product...
http://www.ledwarehouseuk.com/LED-Lights-Bulbs.php?lbid=687
It comes in 4 variables
Cool White / Dimmable
Warm White / Dimmable
Cool White / Non-Dimmable
Warm White / Non-Dimmable
So, in our database we have...
ID Title Colour Dimmable Sensor Price ParentID Delete
687 Light Bulb 1 Cool White Dimmable No Sensor £5.70 0 2
676 Light Bulb 1 Cool White Dimmable No Sensor £5.70 687 2
333 Light Bulb 1 Warm White Dimmable No Sensor £5.70 687 2
677 Light Bulb 1 Cool White Non-Dimmable No Sensor £5.00 687 2
675 Light Bulb 1 Warm White Non-Dimmable No Sensor £5.00 687 2
The parent product needs to show "Dimmable" is an option (even if it's corresponding product - 676 for example - isn't available) so we mark it as Yes. Same with Sensor (no, in this particular case). Colour is a little more problematic because the product is available in more than one colour.
Anyhoo, I feel that the issue is the same so...on our product detail page we have lookup tables set to check the database for products whose ID is either that of the querystring used to open the detail page or whose parentID is also that value. Here's an example of our dimmable lookup table...
$paramItem_rsDIMM = "-1";
if (isset($row_rsPROD['LEDid'])) {
$paramItem_rsDIMM = $row_rsPROD['LEDid'];
}
mysql_select_db($database_connLED, $connLED);
$query_rsDIMM = sprintf("SELECT DISTINCT LEDprods.LEDdimmable, LEDdimmablename FROM LEDprods INNER JOIN LEDdimm ON LEDprods.LEDdimmable = LEDdimm.LEDdimmable WHERE LEDid = %s OR LEDparentID = %s", GetSQLValueString($paramItem_rsDIMM, "int"), GetSQLValueString($paramItem_rsDIMM, "int"));
$rsDIMM = mysql_query($query_rsDIMM, $connLED) or die(mysql_error());
$row_rsDIMM = mysql_fetch_assoc($rsDIMM);
$totalRows_rsDIMM = mysql_num_rows($rsDIMM);
So this shows a list of options...
Dimmable
Non-Dimmable
However, if the dimmable products aren't available (products 676 and 333) "dimmable" will still show as a value in the lookup drop-down because the parent product has it marked as yes.
How do I ensure that the lookup tables ignore the parent product values?
Issue 2
When the user adds to cart, the correct product is added to the cart however I had created a link from the product thumbnail and product title back to the product detail page however, because the product code will not be the parent product ID it returns us to the product detail page but no drop-down menus are available. I've tried adding a "parentID" field to the cart object and, on add to cart, have it carry over to the basket page however when I do this I get a PHP error on the cart quantity....
Notice: Undefined variable: ATC_itemQuantity in /home/led2014/public_html/LED-Lights-Bulbs.php on line 148
Line 148 is…
$ATC_itemQuantity = floatval($ATC_itemQuantity);
Hope you can help.
Thank you.
NJ