SharingDOODLES Posted June 26, 2008 Share Posted June 26, 2008 Hello , I will do my best to explain my situation, I have installed the following contribution as i needed checkboxes for my attributes, attributes sets plus http://www.oscommerce.com/community/contributions,3610 Now to make life easyer i have also installed this contribution options as images http://www.oscommerce.com/community/contributions,1467 However no i have a small issue, By defauly the options as images uses a radio button but i need checkboxes, so i changed the bit of code to give me checkboxes but the problem is when i add some to my basket it only adds 1 and not all that iv selected, if you get what i mean, so i have tried combining the 2 contributions as the "attributes sets pllus" just uses a "switch" statpment but i am really beginning to loose the plot, here is the original "options as images" $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 = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> <table border="0" cellspacing="0" cellpadding="2"> <tr> <?php echo '<td class="main" colspan="2">' . TEXT_PRODUCT_OPTIONS . '<br>Please select your desired option using the buttons provided'; ?> <?php if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true') echo '<br>Click the images to enlarge';?> </td> </tr> <?php $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_images_enabled 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 = '" . (int)$languages_id . "' order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, 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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while($products_options = tep_db_fetch_array($products_options_query)){ $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'], 'thumbnail' => $products_options['products_options_values_thumbnail']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } ?> <tr> <td class="main" valign="top"><?php echo $products_options_name['products_options_name'] . ':'; ?></td> <?php if ($products_options_name['products_options_images_enabled'] == 'false'){ echo '<td class="main">' . tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '</td></tr>'; } else { $count=0; echo '<td class="main"><table><tr>'; foreach ($products_options_array as $opti_array){ echo '<td><table cellspacing="1" cellpadding="0" border="0">'; if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true') echo '<td align="center"><a href="java script:popupWindow(\'' . tep_href_link(FILENAME_OPTIONS_IMAGES_POPUP, 'oID=' . $opti_array['id']) .'\')">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</a></td></tr>'; else echo '<tr><td align="center">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</td></tr>'; echo '<tr><td class="main" align="center">' . $opti_array['text'] . '</td></tr>'; echo '<tr><td align="center"><input type="checkbox" name ="id[' . $products_options_name['products_options_id'] . ']" value="' . $opti_array['id'] . '" checked></td></tr></table></td>'; $count++; if ($count%OPTIONS_IMAGES_NUMBER_PER_ROW == 0) { echo '</tr><tr>'; $count = 0; } } echo '</table>'; } ?> </td></tr> <?php } ?> </table> <?php } ?> Does anyone know How i would go about making them checkboxes that work when added to the cart? If you need more info then please let me know Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 26, 2008 Author Share Posted June 26, 2008 sorry the first contribution should be option type http://addons.oscommerce.com/info/160 as i have already managed to intergrate the other one, Here is the switch statment that it uses $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment 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 = '" . (int)$languages_id . "' order by attribute_sort desc"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { //clr 030714 add case statement to check option type switch ($products_options_name['products_options_type']) { case PRODUCTS_OPTIONS_TYPE_TEXT: //CLR 030714 Add logic for text option $products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); $tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'"> ' . $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { $tmp_html .= '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .')'; } ?> <tr> <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td> <td class="main"><?php echo $tmp_html; ?></td> </tr> <?php break; case PRODUCTS_OPTIONS_TYPE_TEXTAREA: //CLR 030714 Add logic for text option $products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); $tmp_html = '<textarea onKeyDown="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" onKeyUp="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" onFocus="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" wrap="virtual" name="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" rows=5 id="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] . '"></textarea> <div id="progressbar' . $products_options_name['products_options_id'] . '" class="progress"></div> <script>textCounter(document.getElementById("id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']"),"progressbar' . $products_options_name['products_options_id'] . '",' . $products_options_name['products_options_length'] . ')</script>';?> <!-- DDB - 041031 - Form Field Progress Bar //--> <tr> <?php if ($products_attribs_array['options_values_price'] != '0') { ?> <td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ' ' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ')'; ?></td> <?php } else { ?> <td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ')'; ?></td> <?php } ?> <td class="main"><?php echo $tmp_html; ?></td> </tr> <?php break; case PRODUCTS_OPTIONS_TYPE_RADIO: //CLR 030714 Add logic for radio buttons $tmp_html = '<table>'; $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 . "'"); //$checked=true; // START vEDIT if(!isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])){ $no_value = true; } // END vEDIT while ($products_options_array = tep_db_fetch_array($products_options_query)) { // START vEDIT if ($products_options_array['products_options_values_id'] == $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']] || $no_value) { //echo 'true'; $checked = true; $no_value = false; } else { //echo 'false'; $checked = false; } // END vEDIT $tmp_html .= ''; $tmp_html .= tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array['products_options_values_id'], $checked); //$checked = false; $tmp_html .= $products_options_array['products_options_values_name']; $tmp_html .=$products_options_name['products_options_comment']; if ($products_options_array['options_values_price'] != '0') { $tmp_html .= '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } $tmp_html .= '</tr></td>'; } $tmp_html .= '</table>'; ?> <div class="attributes_radio"> <div class="attributes_holder_radio"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_radio"><br /><br /> <?php echo $tmp_html; ?><?PHP echo $products_options_name['products_options_comment']; ?></div><br /><br /> </div><?php break; case PRODUCTS_OPTIONS_TYPE_CHECKBOX_2: $tmp_html = '<table>'; $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 . "'"); //$checked=true; // START vEDIT if(!isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])){ $no_value = true; } // END vEDIT while ($products_options_array = tep_db_fetch_array($products_options_query)) { // START vEDIT if ($products_options_array['products_options_values_id'] == $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']] || $no_value) { //echo 'true'; $checked = true; $no_value = false; } else { //echo 'false'; $checked = false; } // END vEDIT $tmp_html .= ''; //$checked = false; $tmp_html .= $products_options_array['products_options_values_name']; $tmp_html .=$products_options_name['products_options_comment']; if ($products_options_array['options_values_price'] != '0') { $tmp_html .= '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } $tmp_html .= '</tr></td>'; } $tmp_html .= '</table>'; //CLR 030714 Add logic for checkboxes $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'order by options_id"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); // START vFIX $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } // END vFIX /////////////////////////////////////////////////////////// //////////////////////////////////////// ////////////////////////////// ////////////////// ///////// ////// ?> <div class="attributes_checkbox_2"> <div class="attributes_holder_checkbox_2"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_checkbox_2"> <?PHP // START vFIX //echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id'], $boxchecked); // END vFIX echo $tmp_html; echo $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div></div><div style="clear:both"> </div>'; break; case PRODUCTS_OPTIONS_TYPE_CHECKBOX: //CLR 030714 Add logic for checkboxes $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); // START vFIX $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } // END vFIX ?> <div> <div class="attributes_1"> <div class="attributes_holder_1"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_1"> <?PHP // START vFIX //echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id'], $boxchecked); // END vFIX echo $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div><div> '; break; case PRODUCTS_OPTIONS_TYPE_LAYOUTS: //CLR 030714 Add logic for checkboxes $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); // START vFIX $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } // END vFIX ?> <div> <div class="attributes_layouts_1"> <div class="attributes_holder_layouts_1"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_layouts_1"> <?PHP // START vFIX //echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id'], $boxchecked); // END vFIX echo $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div><div> '; break; default: //clr 030714 default is select list //clr 030714 reset selected_attribute variable $selected_attribute = false; // EOF Option Type Feature $products_options_array = array(); // BOF Linkmatics attributes sets plus $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pase.sort_order FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS . " pas2pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " pas, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " pase, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . $products_options_name['products_options_id'] . "' AND pas2pa.products_id = pa.products_id AND pas.products_attributes_sets_id = pas2pa.products_attributes_sets_id AND pas.products_options_id = pa.options_id AND pase.products_attributes_sets_id = pas.products_attributes_sets_id AND pase.options_values_id = pa.options_values_id AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . $languages_id . "' ORDER BY pase.sort_order, pa.options_values_id"); // >>>>> BOF Linkmatics attributes sets plus patch v1.01 if (tep_db_num_rows($products_options_query)== 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 , pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . $products_options_name['products_options_id'] . "' AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . $languages_id . "' ORDER BY pa.options_values_id"); } // <<<<< EOF Linkmatics attributes sets plus patch v1.01 // EOF Linkmatics attributes sets plus while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } ?> <div style="clear:both"> </div> <div class="attributes_dropdown"> <div class="attributes_holder_dropdown"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_dropdown"><?php // BOF Option Type Feature //echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . $products_options_name['products_options_comment']; echo $value_name[products_options_values_image]; // EOF Option Type Feature ?></div></div><div style="clear:both"> </div> <?php // BOF Option Type Feature } // ends the switch clause // EOF Option Type Feature } it just uses a switch statment but i cant manage to get it working in with "options as images" would really appreciate some help, even if its just a case of making the checkboxes work in the "options as images" as at the moment it uses radio buttons Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 26, 2008 Author Share Posted June 26, 2008 Getting closer i think, This is an example of 1 of the break statments used, (option type http://addons.oscommerce.com/info/160) case PRODUCTS_OPTIONS_TYPE_CHECKBOX: //CLR 030714 Add logic for checkboxes $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); // START vFIX $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } // END vFIX ?> <div> <div class="attributes_1"> <div class="attributes_holder_1"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_1"> <?PHP // START vFIX //echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id'], $boxchecked); // END vFIX echo $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div><div> '; break; I have pulled appart the other contribution and tryed intergrating it into one of the break statments, Here is what i have so far: case PRODUCTS_OPTIONS_TYPE_CHECKBOX: $products_attribs_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, 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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while($products_options = tep_db_fetch_array($products_attribs_query)){ $products_attribs_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'], 'type' => $products_options['products_options_type'], 'thumbnail' => $products_options['products_options_values_thumbnail']); if ($products_options['options_values_price'] != '0') { $products_attribs_array[sizeof($products_attribs_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } foreach ($products_attribs_array as $opti_array){ echo '<div class="attributes_1"> <div class="attributes_holder_1"> <h2>' . $products_options_name['products_options_name'] . ' </h2> </div> <div class="attributes_foot_1">'; echo '' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail']) . ''; echo '<br />' . $opti_array['text'] . ''; echo '<p>' . tep_draw_checkbox_field('id[' . $opti_array['text'] . ']" value="' . $opti_array['id'], $boxchecked) . ' </div></div>'; } break; As it is i now: if i select a few attributes and go to checkout its showing the right amount of added attributes but with no name or price added Could someone please run over the code to see what i am missing please Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 27, 2008 Author Share Posted June 27, 2008 It is something to do with the array it uses, I have checked the values that are passed by the checkboxes and i can get one of the values but not the other if you get what i mean, example: On my site that uses just the " option type http://addons.oscommerce.com/info/160 " the chack box it outputted like the following and for each checkbox the name changes but the value stays the same : <input type="checkbox" value="85" name="id[10]"/> with the extra break statment i get the following output, the name changes for each of the checkboxes, <input type="checkbox" name="id[40]"/> Right i know i need that value in there but i am really stuck as i have been trying various things to get it workin, Here is my case statment so far: case PRODUCTS_OPTIONS_TYPE_CHECKBOX: $products_options_query = tep_db_query("select distinct pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, 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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while($products_options_name = tep_db_fetch_array($products_options_query)){ $products_attribs_array[] = array('id' => $products_options_name['products_options_values_id'], 'text' => $products_options_name['products_options_values_name'], 'type' => $products_options_name['products_options_type'], 'thumbnail' => $products_options_name['products_options_values_thumbnail']); if ($products_attribs_array['options_values_price'] != '0') { $products_attribs_array[sizeof($products_attribs_array)-1]['text'] .= ' (' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_options_name['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'], $products_attribs_array['options_values_id'])) .') '; } } foreach ($products_attribs_array as $opti_array){ echo '<div class="attributes_1"> <div class="attributes_holder_1"> <h2>' . $opti_array['text'] . ' </h2> </div> <div class="attributes_foot_1">'; echo '' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail']) . ''; echo '<br />' . $opti_array['text'] . ''; echo '<p>' . tep_draw_checkbox_field('id[' . $opti_array['id'] . ']', $opti_array['products_options_id'], $boxchecked) . ' </div></div>'; } break; Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 27, 2008 Author Share Posted June 27, 2008 I am even willing to offer a small reward to anyone who can make it work, Right, little update, (incase anyone can help) as mentioned its something to do with the values being passed, The main part i have been concentrating on is the "checkbox" itself minor changes made compared to above post: echo '<p>' . tep_draw_checkbox_field('id[6]', $opti_array['id'], $boxchecked) . ' </div></div>'; if i set the "id" to a fixed "6" it will pass the first checkbox selected including extra cost and the options name, but only the first, (so its not looping properly i guess) so i now have the 2 values being passed but its only adding the one option, :angry: if i add the "products_options_id" to the top query in the "case" statment and then add it to the array below assigned to "id2" and then change the "select" box to the following it will only show "id" as 1: (again i guess not looping properly) echo '<p>' . tep_draw_checkbox_field('id[' . $opti_array['id2'] . ']', $opti_array['id'], $boxchecked) . ' </div></div>'; Please could someone lend a hand, please Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 27, 2008 Author Share Posted June 27, 2008 this way round it adds all selected options but no name or extra cost echo '<p>' . tep_draw_checkbox_field('id[' . $opti_array['id'] . ']', '6', $boxchecked) . ' </div></div>'; this way round it adds only 1 but includs the name and extra cost echo '<p>' . tep_draw_checkbox_field('id[6]', $opti_array['id'], $boxchecked) . ' </div></div>'; so close but yet so far... Quote Link to comment Share on other sites More sharing options...
SharingDOODLES Posted June 28, 2008 Author Share Posted June 28, 2008 Hello Again, I know i am just missing something really simple, reward to anyone who solves it lol I have made lots of changes to make the new "case" statment like the original, Here is the original case statment case PRODUCTS_OPTIONS_TYPE_CHECKBOX: //CLR 030714 Add logic for checkboxes $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); // START vFIX $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } // END vFIX ?> <div> <div class="attributes_1"> <div class="attributes_holder_1"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_1"> <?PHP // START vFIX //echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id'], $boxchecked); // END vFIX echo $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div><div> '; break; Here is my new case statment case PRODUCTS_OPTIONS_TYPE_CHECKBOX: $products_options_query = tep_db_query("select distinct pov.products_options_values_id, products_options_id, options_values_id, products_options_values_thumbnail, products_options_comment, products_options_id, pov.products_options_values_name, pov.products_options_values_thumbnail, pa.options_values_price, pa.price_prefix from vikingonly_products_options, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_attribs_array = tep_db_fetch_array($products_options_query)) { $boxchecked = false; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $boxchecked = true; }else { $boxchecked = false; } ?> <div> <div class="attributes_1"> <div class="attributes_holder_1"> <h2> <?php echo $products_options_name['products_options_name'] . ':'; ?></h2> </div> <div class="attributes_foot_1"> <?PHP echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_attribs_array['options_values_id'] . ']', $products_options_name['products_options_id'], $boxchecked); echo '' . tep_image(DIR_WS_IMAGES . 'options/' . $products_attribs_array['products_options_values_thumbnail']) . ''; echo $products_attribs_array['products_options_values_name']; if ($products_attribs_array['options_values_price'] != '0') { echo '<br />(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } echo '</p></div></div><div> '; } break; I have added 2 checkboxes echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']); echo '<p>' . tep_draw_checkbox_field('id[' . $products_attribs_array['options_values_id'] . ']', $products_options_name['products_options_id'], with the first one i get an output of the following with the value changing for each one and the id staying the same, <input type="checkbox" value="38" name="id[6]"/> With the second i get the following with the name id changing for each one witch is how the original option type contribution works (http://addons.oscommerce.com/info/160) <input type="checkbox" value="6" name="id[38]"/> if i tick the first of the 2 tickboxes it will pass the name and price of just one option, If i tick the second of the 2 tickboxes it passes them to the cart but with no name or price ajustment, I really am stuck on this, please can someone help, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.