Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Eliminate "Please Choose" when only One attribute option is present?

Eliminate "Please Choose" when only One attribute option is present?

Locked

Views: 4,950

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
19 Sep 2008, 1:10 AM
#1
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Eliminate "Please Choose" when only One attribute option is present?

Is it possible to not display the "Please Choose" when only a single attribute option is present?

Is so, can it be done from the Admin console?

Or must I use a hack in one of the PHP files?

Thanks,
Daniel

19 Sep 2008, 3:26 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Eliminate "Please Choose" when only One attribute option is present?

If you want that single attribute to be selected when they add-to-cart, you'll need to get all the attribute details onto the product-listing page too ... otherwise they won't be included.

19 Sep 2008, 4:00 AM
#3
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

I am OK with displaying that attribute, I just find it a confusing for the customer to "Please Choose" when only one option is available (and of course already selected).

I tried replacing that radio button attribute with a read-only one, but that killed the download functionality... IMHO this is a bug (unless I am missing something).

19 Sep 2008, 4:21 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Eliminate "Please Choose" when only One attribute option is present?

While you may consider it a bug, it's just simply not designed that way in v1.3.x.
It's actually a feature limitation: If you have have any attributes, you can only add-to-cart via the product page, since that's the only page where any attribute details are included with the add-to-cart button, regardless of the type of attributes assigned to the product.

19 Sep 2008, 2:22 PM
#5
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

Well, I am caught in a "chicken and the egg" situation: I don't really need any attributes for my downloadable product, but the way I understand it, ZenCart requires at least one attribute to allow a product to be downloadable.

So, I chose a bogus attribute (i.e. doesn't really effect anything in the download process or the product's price, etc.) and that enabled the download functionality.

Then, as I was trying to polish this, I thought perhaps eliminate the "Please Choose", when that single (bogus) attribute already has its default (and only) option selected. It didn't work.

So, my (future) customers will have to live with that confusing "Please Choose". :lamo:

19 Sep 2008, 3:20 PM
#6
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Eliminate "Please Choose" when only One attribute option is present?

If you search in Admin -Tools - Developers Tool Kit for 'please choose', you'll see a list of files where those words appear. You could just find where that's defined and remove the text from the define statement (but leave the single quotes).

19 Sep 2008, 6:33 PM
#7
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

stevesh:

If you search in Admin -Tools - Developers Tool Kit for 'please choose', you'll see a list of files where those words appear. You could just find where that's defined and remove the text from the define statement (but leave the single quotes).
Thanks. That basically positively answers my 3rd question in my post that started this thread:
zcnb:

Or must I use a hack in one of the PHP files?

No problem. I have done much more serious hacking. :smile:

I just needed to make sure that I am not missing a feature in the Admin console.

17 Oct 2008, 11:53 PM
#8
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

I had the same problem and found an alternative solution. My aim was to hide the entire attributes section because showing the option will just be confusing to the customer.
In this particular case there is only a single attribute with one single option. It only serves to enable the download and IMO should not be displayed at all:

  1. Create a new class hidden in your stylesheet.css
.hidden{ position:absolute; visibility:hidden; }
  1. Open the file tpl_modules_attributes.php in a text editor
  2. Now find the line:
<div id="productAttributes">

and replace it with

<div id="productAttributes" class="hidden">

While the attributes section is now hidden it will still be evaluated when the add to cart button is submitted.

Note: In my case I needed to hide the attributes section only for a single product category. I achieved this by replacing the line

<div id="productAttributes">

with this conditional statement:

<?php
if( $cPath == '3' ){
    echo '<div id="productAttributes" class="hidden">';
}else{
    echo '<div id="productAttributes">';
}
?>

Andreas

26 Oct 2008, 9:42 AM
#9
greydayrecords avatar

greydayrecords

New Zenner

Join Date:
Oct 2008
Location:
Portland, OR
Posts:
16
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

dause--I registered solely so I could say THANK YOU. We recently migrated from Miva to Zen Cart and I've slowly been trying to modify it to do exactly what I want it to (which has a bit of a learning curve, to be sure). This bit of code sorted out one of my biggest problems, I was able to hide both of my single option attributes. Thank you, thank you, thank you!

27 Oct 2008, 5:42 AM
#10
greydayrecords avatar

greydayrecords

New Zenner

Join Date:
Oct 2008
Location:
Portland, OR
Posts:
16
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

GAH! Spoke too soon. It worked like a charm, but we had two customers place orders that were NOT linked to the download files associated with the attribute. I ran a test order with the above code and with it /**ed out, and the test with the code had no download connected to it, the one without the code did (also, removing the code did not return download access to the previous orders). Any ideas? I'm going to play with it a bit tonight, but if anyone else could weigh in that would be ace. :)

27 Oct 2008, 7:14 AM
#11
greydayrecords avatar

greydayrecords

New Zenner

Join Date:
Oct 2008
Location:
Portland, OR
Posts:
16
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

Oh, and a footnte--no need to add the "hidden" style, at least not in 1.3.8, there's already a style called "hiddenField". So for example, I still use dause's code, but I dumped the download category and just use it for a junk category that I use to get rid of quantity boxes by replacing class="hidden" with class="hiddenField". I've tried the download thing both ways (hidden and hiddenField) with no luck.

27 Oct 2008, 7:28 AM
#12
gjh42 avatar

gjh42

Black Belt

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

Re: Eliminate "Please Choose" when only One attribute option is present?

Not addressing the problem with downloads not working (I don't use them so have nothing to say there), it is not necessary to add a class or modify tpl_modules_attributes.php at all.

If you only have downloadables in your shop, you can apply the hiding styling to #productAttributes directly.
If you want to hide the attributes only for say category 3, make an additional stylesheet named c_3.css with content

#productAttributes {position:absolute; visibility: hidden;}

This will apply only to category 3.

27 Oct 2008, 11:41 AM
#13
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

If you only have downloadables in your shop, you can apply the hiding styling to #productAttributes directly. (...)

Wow, that's neat! where is this stuff documented?
Thanks!

27 Oct 2008, 11:54 AM
#14
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

greydayrecords:

Oh, and a footnte--no need to add the "hidden" style, at least not in 1.3.8, there's already a style called "hiddenField".

Thanks for pointing that out. it looks like the hiddenField class was missing from the template I used as a starting point for my shop design. If you are using the hiddenField style I would suggest that you add the property:
position: absolute;
otherwise the hidden field will still claim some (then empty) space which IMO does not look so nice.

I've tried the download thing both ways (hidden and hiddenField) with no luck.
Is the hidden option displayed in the shopping cart?
If not then it was not selected.
You need to make sure that the checkbox is selected by default.
You do this in admin > catalog > attributes controller.

Andreas

27 Oct 2008, 5:08 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Eliminate "Please Choose" when only One attribute option is present?

dause:

Wow, that's neat! where is this stuff documented?

See the /docs/ folder of your Zen Cart files.

27 Oct 2008, 5:56 PM
#16
gjh42 avatar

gjh42

Black Belt

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

Re: Eliminate "Please Choose" when only One attribute option is present?

And the additional stylesheet conventions are described in
/includes/templates/template_default/css/CSS_read_me.txt.

28 Oct 2008, 12:53 PM
#17
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: Eliminate "Please Choose" when only One attribute option is present?

gjh42:

And the additional stylesheet conventions are described in
/includes/templates/template_default/css/CSS_read_me.txt.

Thanks!