Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Hiding the 'default' option for required attributes

Hiding the 'default' option for required attributes

Locked

Views: 1,489

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
13 Dec 2007, 11:12 PM
#1
xtinexoop avatar

xtinexoop

New Zenner

Join Date:
Mar 2004
Posts:
34
Plugin Contributions:
1

Hiding the 'default' option for required attributes

Hi

I would like to hide the default attribute - either when it is a radio box or as a dropdown so that the user only 'sees' the actual options rather than the one that says 'please choose' or whatever.

My product I am testing on is at http://singleswalking.co.uk/index.php?main_page=product_info&cPath=2_5&products_id=9

I had thought to make the default option sort order something like 99 and then use an if statement to say if the option is 99 then don't display it. Would that work?

I don't know PHP very well so I am not sure I can fiddle the code although I sort of understand the logic I want.

Any help gratefully received.

Christine

14 Dec 2007, 12:03 AM
#2
xtinexoop avatar

xtinexoop

New Zenner

Join Date:
Mar 2004
Posts:
34
Plugin Contributions:
1

Re: Hiding the 'default' option for required attributes

Hi

I have moved a bit closer... by adding the following code I now have it doing something different for the default option as long as that default option is 'Please choose' and has a stock level of 0...

But what I really want is not to display it at all - I tried that, but I still got the radio button.... I am actually happy to have the text 'Please choose' but I don't want the radio button to show.

Help!

Christine

Here is my code

   if ($products_options->fields['quantity'] > 0) 
   {
    $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_IN_STOCK . ']';
   } else {

//next line checks to see if name of option is Please choose - so doesn't display out of stock message
if ($products_options->fields['products_options_values_name'] == 'Please choose')
{
$products_options_details = '' . TEXT_ATTRIBUTES_DEFAULT . '';
}
else {
$products_options_details = $products_options->fields['products_options_values_name'] . '[' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']';
}
}

  } else {
   // don't show option value name on TEXT or filename
   $products_options_details = '';
  }
  if ($products_options_names->fields['products_options_images_style'] >= 3) {
   $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
14 Dec 2007, 12:43 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Hiding the 'default' option for required attributes

You can suppress the display of any particular radiobutton with CSS, as they all have unique id's assigned by Zen Cart. For example, for your Quainton 1st January (25-45):

input#attrib-2-4, input#attrib-2-4+label {display: none;}

The labels are all assigned the same class, but you can address a particular label by combining it with the input ahead of it (input#attrib-2-4+label). Class name not even needed here!

I believe you will find that all instances of this particular radiobutton will now be suppressed, as the id is based on the option name and value.

14 Dec 2007, 1:21 AM
#4
xtinexoop avatar

xtinexoop

New Zenner

Join Date:
Mar 2004
Posts:
34
Plugin Contributions:
1

Re: Hiding the 'default' option for required attributes

Thanks!

It seems to work great in Firefox, but not in IE???

Tis late so will try again in the morning, maybe its a cache problem.

Christine

14 Dec 2007, 2:11 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Hiding the 'default' option for required attributes

I wouldn't be surprised if the input#attrib-2-4+label didn't work in IE, as IE6 doesn't know how to handle adjacent sibling selectors (the "+"). But the input#attrib-2-4 should work in any browser, because that is fundamental CSS.

16 Dec 2007, 10:09 PM
#6
xtinexoop avatar

xtinexoop

New Zenner

Join Date:
Mar 2004
Posts:
34
Plugin Contributions:
1

Re: Hiding the 'default' option for required attributes

Thanks Glenn

I wasn't sure what to do about the bit that IE wouldn't support - so I took it out altogether and now it works in both browsers!

Excellent!

Christine