AndrewC Posted April 19, 2004 Posted April 19, 2004 I have coded the options to be chosen by checkboxes. I can choose either option but not both together. If you choose both options only one is carried to the cart. Any ideas http://www.fit-smart.com/catalog/product_i.../products_id/35
AndrewC Posted April 19, 2004 Author Posted April 19, 2004 <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { echo '<table border="0" cellpadding="0" cellspacing"0"><tr>'; $rows = 0; $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; if (($rows / 2) == floor($rows / 2)) { $align = 'right'; }else { $align = 'left'; } echo ' <td align="'.$align.'" class="catholder" style="width: ' . $width . '" valign="top"> <table border="0" width="200" cellspacing="0" cellpadding="0"> <tr> <td width="100%" height="14" class="menu-grey">? ' . $products_options_name['products_options_name'] . '</td> </tr> <tr> <td class="menu-darkgrey">'; $selected = 0; $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { echo '<input type="checkbox" name="id[' . $products_options_name['products_options_id'] . ']" value="'. $products_options['products_options_values_id'].'"> ' . $products_options['products_options_values_name']. ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .')<br> '; } echo '</td> </tr></table></td>' . "\n"; if ((($rows / 2) == floor($rows / 2)) && ($rows != tep_db_num_rows($products_options_name_query))) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } echo '</tr> </table> </div>'; } ?>
Aziz Posted April 19, 2004 Posted April 19, 2004 btw it would've been more interesting to read the code if it LOOKS like a code... --------------------------------
Aziz Posted April 19, 2004 Posted April 19, 2004 Just for my info... <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { echo '<table border="0" cellpadding="0" cellspacing"0"><tr>'; $rows = 0; $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; if (($rows / 2) == floor($rows / 2)) { $align = 'right'; }else { $align = 'left'; } echo ' <td align="'.$align.'" class="catholder" style="width: ' . $width . '" valign="top"> <table border="0" width="200" cellspacing="0" cellpadding="0"> <tr> <td width="100%" height="14" class="menu-grey">? ' . $products_options_name['products_options_name'] . '</td> </tr> <tr> <td class="menu-darkgrey">'; $selected = 0; $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { echo '<input type="checkbox" name="id[' . $products_options_name['products_options_id'] . ']" value="'. $products_options['products_options_values_id'].'"> ' . $products_options['products_options_values_name']. ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .')<br> '; } echo '</td> </tr></table></td>' . "\n"; if ((($rows / 2) == floor($rows / 2)) && ($rows != tep_db_num_rows($products_options_name_query))) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } echo '</tr> </table> </div>'; } ?> --------------------------------
Aziz Posted April 19, 2004 Posted April 19, 2004 Man i think u should improve the way you write the code.. But can i ask u something? this code is to show the checkboxes, which it works fine? I think the problem is when you view the cart items, right? peace, --------------------------------
AndrewC Posted April 19, 2004 Author Posted April 19, 2004 My problem is, if i want to add both options to the cart as well as the product it will only add one of the options.
Aziz Posted April 19, 2004 Posted April 19, 2004 Can u check in ur database if both options were added it, or only 1.. Maybe the mistake (i think) is viewing the added options, not entering them peace, --------------------------------
AndrewC Posted April 19, 2004 Author Posted April 19, 2004 They are both there. They are listed as below. Option Name -> Option Values Electrodes -> small pads Electrodes -> large pads
Recommended Posts
Archived
This topic is now archived and is closed to further replies.