JNKeil Posted January 7, 2009 Share Posted January 7, 2009 Hi. Please help. I will like to remove the product attribute drop-down box if there is only one attribute. When only one attribute is listed, the attribute, will be shown as normal text.! Link to comment Share on other sites More sharing options...
spooks Posted January 7, 2009 Share Posted January 7, 2009 Use tep_db_num_rows & dont use drop if = 1 Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
JNKeil Posted January 7, 2009 Author Share Posted January 7, 2009 Hi Sam. Will you please tell me where and what to change in this line. <?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?> I believe that this is here I have to change something... :-) Use tep_db_num_rows & dont use drop if = 1 Link to comment Share on other sites More sharing options...
spooks Posted January 7, 2009 Share Posted January 7, 2009 yes, loop around with if (tep_db_num_rows ($products_options_query) != 1) Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
johny_boy Posted February 20, 2009 Share Posted February 20, 2009 yes, loop around with if (tep_db_num_rows ($products_options_query) != 1) Hy Sam i made this line <?php if (tep_db_num_rows ($products_options_query) != 1){ echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); } ?> but now all my text disappears , can you help me? Link to comment Share on other sites More sharing options...
davidrus Posted February 24, 2009 Share Posted February 24, 2009 Hy Sami made this line <?php if (tep_db_num_rows ($products_options_query) != 1){ echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); } ?> but now all my text disappears , can you help me? Not sure if you found the answer yet, but if you didn't, I think I can help. I'm assuming if there is only one attribute, you want to display it, just not in a drop-down box. This is what I did (although it might not be the best way, it works): Go to catalog > includes > functions > html_output.php Paste this function at the bottom of the page, right before the ?> function tep_draw_not_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { global $HTTP_GET_VARS, $HTTP_POST_VARS; if (tep_not_null($parameters)) $field .= ' ' . $parameters; if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) { if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { $default = stripslashes($HTTP_GET_VARS[$name]); } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { $default = stripslashes($HTTP_POST_VARS[$name]); } } for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); } if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } Now go to product_info.php Find: <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td> <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> Replace with: <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td> <?php if (tep_db_num_rows ($products_options_query) != 1) { ?> <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> <?php } else { ?> <td class="main"><?php echo tep_draw_not_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> <?php } ?> Now, if there is only 1 option associated with an attribute, it won't display the drop-down, but if there is more than one, it will. Hope this helps. Link to comment Share on other sites More sharing options...
ruan Posted February 26, 2009 Share Posted February 26, 2009 Go to catalog > includes > functions > html_output.php Paste this function at the bottom of the page, right before the ?> function tep_draw_not_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { global $HTTP_GET_VARS, $HTTP_POST_VARS; if (tep_not_null($parameters)) $field .= ' ' . $parameters; if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) { if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { $default = stripslashes($HTTP_GET_VARS[$name]); } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { $default = stripslashes($HTTP_POST_VARS[$name]); } } for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); } if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } Hi David, I tried adding the code but it generates an SQL from this piece of code. I think this line is the problem. $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); Can you have a look and see if it's as you have it in your site? cheers, ruan Link to comment Share on other sites More sharing options...
davidrus Posted February 26, 2009 Share Posted February 26, 2009 Hi David, I tried adding the code but it generates an SQL from this piece of code. I think this line is the problem. $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); Can you have a look and see if it's as you have it in your site? cheers, ruan Can you copy and paste the error your getting for me? I don't get an error on my site. Thanks. Link to comment Share on other sites More sharing options...
ruan Posted February 27, 2009 Share Posted February 27, 2009 Can you copy and paste the error your getting for me? I don't get an error on my site. Thanks. hey, thanks for the reply :) when i look at the code in dreamweaver I can see that all of this : ')); } if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } ?> is in red, not black and blue with a bit of red. henc my comment about this line maybe having an error: { $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); } Also, the actual error points to the line above. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in Shop\includes\functions\html_output.php on line 347 cheers r Link to comment Share on other sites More sharing options...
davidrus Posted February 27, 2009 Share Posted February 27, 2009 hey, thanks for the reply :) when i look at the code in dreamweaver I can see that all of this : ')); } if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } ?> is in red, not black and blue with a bit of red. henc my comment about this line maybe having an error: { $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')); } Also, the actual error points to the line above. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in Shop\includes\functions\html_output.php on line 347 cheers r I see what the problem is. The post isn't displaying the html correctly. Not sure how to fix that. The correct line is this: for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= tep_output_string($values[$i]['text'], array('"' => '"', '\'' => '&_#_0_3_9;', '<' => '<', '>' => '>')); } Remove the underscores from &_#_0_3_9; and you should be good to go. If anyone can tell me the proper way to display code without the browser trying to interpret it, I would be most appreciative. Link to comment Share on other sites More sharing options...
apephoto222 Posted April 5, 2011 Share Posted April 5, 2011 Im trying to do the same thing. Have you found anything out about how to do it? Link to comment Share on other sites More sharing options...
Guest Posted December 28, 2011 Share Posted December 28, 2011 I know this is pretty old, but I wonder if anyone still following this topic has found a solution. I have tried everything recommended and it did not work. I have v2.3.1 and found the code does not look exactly as stated above, but I made all the necessary adjustments (I think.) Let me know if anyone has found a solution! Thanks! Link to comment Share on other sites More sharing options...
foxp2 Posted December 29, 2011 Share Posted December 29, 2011 another way to do it (no need to create a function) change (in product_info.php) : <?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?> with : <?php echo (sizeof($products_options_array) == 1 ) ? tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array[0]['id'], true) . $products_options_array[0]['text'] : tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?> ^_^ Link to comment Share on other sites More sharing options...
Guest Posted December 29, 2011 Share Posted December 29, 2011 That's great! Merci, Laurent! However, if I can do without the radio button, that would be even better. I made a little tweak to your code and erased the 'text' (' '), so all I have is a radio button... so much better than before. Any other thoughts? Merci beaucoup! Link to comment Share on other sites More sharing options...
foxp2 Posted December 29, 2011 Share Posted December 29, 2011 However, if I can do without the radio button, that would be even better. yes, it's possible. tep_draw_hidden_field is the key : <?php echo (sizeof($products_options_array) == 1 ) ? tep_draw_hidden_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array[0]['id']) . $products_options_array[0]['text'] : tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?> Link to comment Share on other sites More sharing options...
Guest Posted December 29, 2011 Share Posted December 29, 2011 BEAUTIFUL!!!!!!!!!!!!!!!!! Thanks!!!!!!!!!! Yikes, I can't believe it was that easy... Link to comment Share on other sites More sharing options...
patrickluursema Posted January 22, 2012 Share Posted January 22, 2012 Works like a charm! Regards, Patrick Luursema Link to comment Share on other sites More sharing options...
MishaB Posted January 25, 2012 Share Posted January 25, 2012 Help! I need a charm, too ... :rolleyes: I have a similar wish, but the solution above doesn't work for me. I have 6 attributes in the drop-down field, but don't want to show them to customers. What do I need to do that always the first attribut is selected and no drop-down menu is shown? I would be thankful for any help or ideas! Link to comment Share on other sites More sharing options...
Guest Posted January 25, 2012 Share Posted January 25, 2012 @@MishaB, Your scenario is a bit confusing. Why do you have 6 attributes but the customer is only allowed to choose 1 ? If there is only 1 to be selected, then remove the other 5 ! Chris Link to comment Share on other sites More sharing options...
MishaB Posted January 25, 2012 Share Posted January 25, 2012 @@DunWeb: I didn't wanted to write a novel (which I usually do when I want to explain something) ... :) The customer always receive 6 different download links at the end of the purchase. I wanted to give them a lot of options and they can choose by themselfes in the end what works best for them. I didn't wanted to put every file in a zip-folder, so I created 6 different options which are all available at the checkout_success.php. Now, I just don't want to confuse the customer before buying (because you see - there is no need for it!) I want to make everything as customer friendly as possible ... :) Link to comment Share on other sites More sharing options...
roneada Posted April 14, 2012 Share Posted April 14, 2012 i have the remove dropdown menu with radio buttons, but your solutions not work, how to have for remove the dropdown? thanks! Link to comment Share on other sites More sharing options...
♥14steve14 Posted April 14, 2012 Share Posted April 14, 2012 To get radio buttons working you need to add to your includes/functions/general.php //// // Output a form radio menu for product info page maniac101 function tep_draw_radio_menu($name, $values, $default = '', $parameters = '', $required = false) { $field ='<table border="0" cellspacing="0" cellpadding="0"><tr><td class="main">'; if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); for ($i=0, $n=sizeof($values); $i<$n; $i++) { $value = tep_output_string($values[$i]['id']); $field .= '<input type="radio" name="' . $name . '" value="' . $value . '"'; if ($i == 0) $field .= ' checked'; $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '<br />'; } $field .= '</td></tr></table>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } Then in your products_info.php change tep_draw_pull_down_menu to tep_draw_radio_menu REMEMBER BACKUP, BACKUP AND BACKUP Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.