Remove the product attribute drop-down box if only one attribute
#-19
Posted 07 January 2009 - 03:27 PM
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.!
#-18
Posted 07 January 2009 - 04:51 PM
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.
#-17
Posted 07 January 2009 - 07:28 PM
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... :-)
spooks, on Jan 7 2009, 05:51 PM, said:
#-16
Posted 07 January 2009 - 08:01 PM
if (tep_db_num_rows ($products_options_query) != 1)
Edited by spooks, 07 January 2009 - 08:15 PM.
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.
#-15
Posted 20 February 2009 - 02:19 PM
spooks, on Jan 7 2009, 09:01 PM, said:
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?
#-14
Posted 24 February 2009 - 09:17 PM
johny_boy, on Feb 20 2009, 02:19 PM, said:
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?
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.
#-13
Posted 26 February 2009 - 10:28 AM
davidrus, on Feb 24 2009, 09:17 PM, said:
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
#-12
Posted 26 February 2009 - 06:34 PM
ruan, on Feb 26 2009, 11:28 AM, said:
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.
#-11
Posted 27 February 2009 - 09:13 AM
davidrus, on Feb 26 2009, 06:34 PM, said:
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
Edited by ruan, 27 February 2009 - 09:16 AM.
#-10
Posted 27 February 2009 - 04:35 PM
ruan, on Feb 27 2009, 10:13 AM, said:
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.
#-9
Posted 05 April 2011 - 09:27 PM
#-8
Posted 28 December 2011 - 10:07 PM
#-7
Posted 29 December 2011 - 08:07 AM
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); ?>
Edited by foxp2, 29 December 2011 - 08:07 AM.
#-6
Posted 29 December 2011 - 05:17 PM
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!
#-5
Posted 29 December 2011 - 05:50 PM
vmjarala, on 29 December 2011 - 05:17 PM, said:
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); ?>
#-4
Posted 29 December 2011 - 06:37 PM
Yikes, I can't believe it was that easy...
#-3
Posted 22 January 2012 - 11:33 AM
Regards,
Patrick Luursema
#-2
Posted 25 January 2012 - 04:53 AM
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!
#0
Posted 25 January 2012 - 06:01 AM
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 ... :)
Edited by MishaB, 25 January 2012 - 06:02 AM.









