Chained Attributes and Options

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Not ready for moderation

Downloads

Latest version: 
1.3
Compatibility: 
Ubercart 2.x

After a lot of searching and digging in drupal.org I found out that there's currently no modules that enhance ubercart's core attributes & options functionalities in the following way:

1) establishes dependencies between attributes;
2) establishes dependencies between specified options and attributes;
3) by establishing the above dependencies, the selection/deselection of certain options in certain attributes results in the enabling/disabling of their depending attributes/options.

This module aims to provide a solution for this.

I am aware of the Dependent Attributes module (http://drupal.org/project/uc_dependent_attributes), which is able to define similar dependencies on a per product basis. For each product you create, you have to click into the edit & adjustment tab to disable/enable combinations of options. I assume it works if you have a few products (for example, selling services). But it can be extremely tedious for mid to large size ubercart shops. So I want to build a module that is able to define per product class attributes and options dependencies. That's why this module is needed.

=====================
Some features of this module:
=====================
1) CANO supports two types of dependency between options and attributes: Disable, and Enable.

For example, if on loading your default option of Attribute A is No, and in this case you want to disable the dependant attribute B, then you'll need to define this: "No" of Attribute A --> Disable --> Attribute B. As a result, on loading of any product page of this class, Attribute B is disabled and hidden. And if a customer selects "Yes" of Attribute A, then Attribute B will be enabled and displayed. You can, however, impose dependency of Attribute B on the "Yes" option of Attribute A to either Enable (not necessary but doable) or Disable as well.

2) CANO supports recursive hierarchy of relations. A recursive dependency handler is implemented. See these two scenarios. Say M2M is an option of Attribute A, and Custom Lenght is Attribute B (which has two option: Yes / No), and Length is Attribute C;

i). M2M -> Disables -> Custom Lenght, and Custom Length -> Yes -> Enables -> Length
output : when I selected M2M, the custom length was disabled and hence the Length was too. So it was a positive output.

ii). M2M -> Enables -> Custom Length, and Custom Length -> Yes -> Disables -> Length
ouput : when I selected M2M, the custom Length as enabled and hence the Length was too, as the default selection of custom length was not "Yes". So it was a positvie output.

3) CANO is designed in a way so that even "Required" attributes can be disabled and hidden if necessary. In order to do this, CANO super-imposes "NULL" string to these attributes when customers put the product in shopping cart so that ubercart won't complain. This is very useful because in many situations, there're attributes that you want them to be required if enabled. This is not possible in any other ubercart modules.

4) CANO establishes the dependencies between Attributes and Options in per product-class level. No definition is needed on per product level.

====================
Credits:
====================
This module is maitained by Vizteck Solutions.

Related threads: 

PreviewAttachmentSize
uc_cano-1.1.tar22.5 KB
uc_cano-1.3.zip8.42 KB
Yuri's picture
Offline
Joined: 05/26/2010
Juice: 35
Not compatible with Boost module 6.x-1.18

warning: Cannot modify header information - headers already sent by (output started at ../public_html/sites/all/modules/uc_cano/uc_cano.module:1) in ../public_html/sites/all/modules/boost/boost.module on line 2973
(also white screen of death now and then)

Yuri's picture
Offline
Joined: 05/26/2010
Juice: 35
Have to delete a point space in first line of uc_cano.module

Ok, solved: You have to delete a point and space in the first line of uc_cano.module (the first two characters)

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Have to delete a point space in first line of uc_cano.module

fixed in RC2, together with some other minor changes.

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: Chained Attributes and Options

this is a great idea, but i am getting white screens all over the place: adding, deleting attributes, even just enabling the module...i can delete /6/delete (for instance, if i'm deleting attribute 6) and get back to the page i was on, but i'm having lots of issue with this enabled. wish i was a coder and could help fix, but i don't have a clue where to start, but just so you know...i've got a few other UC add-on extensions enabled, maybe that's a factor?

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Scot, 1) please make sure

Scot,

1) please make sure you're using Drupal 6.x and Ubercart 2.x;
2) please download the latest version 1.0. it should work.

otherwise please let me know. thanks for the report!

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: Scot, 1) please make sure

check and check. does it have to go in the ubercart contrib folder? i have it just in my modules folder...

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: Scot, 1) please make sure

No it doesn't have to. Just in the modules folder will work without any problem. Good luck.

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
still having white screens

still having white screens all over the place once i install and enable this...if I add an attribute option at say admin/store/attributes/9/options/add, when i submit that form i get a white screen. i can remove the /add from the url and i'm returned to where i should be...same thing when adding, editing any attributes or their options.

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: Re: Re: Scot, 1) please make sure

also been getting this a lot:
warning: Cannot modify header information - headers already sent by (output started at /home/alabamar/public_html/letter-creations/sites/all/modules/uc_cano/uc_cano.module:1) in /home/alabamar/public_html/letter-creations/includes/common.inc on line 148.
i don't see anything glaringly wrong with the code at that point in the module, but i'm no developer...

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: still having white screens

actually i'm getting white pages all over the place, not just editing/adding/deleting attributes...getting it after flushing cache, editing products themselves, etc...i can actually just refresh the page and that works too. the submit takes, it's just not bringing the page back...i tried disabling several UC contrib modules i'm using, namely ajax attribute calculations, product power tools and to no avail.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: still having white screens

are you using the latest version 1.o? have you run the update.php script after upgrading this module?

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: Re: Re: still having white screens

sorry, i wish i was having more luck here...did all that and made sure to be using 1.0 (is there a difference b/w the .zip and the .tar file?), ran update.php, now i get

user warning: Unknown column 'type' in 'field list' query: SELECT dependent_aid, type FROM uc_cano WHERE oid = '0' AND pcid = 'letters' in {path to my site}/sites/all/modules/uc_cano/uc_cano.module on line 71

same msg repeats with oid='1' and oid='23' on most pages, sometimes all 3 repeat multiple times...

not sure what i could be doing wrong...seems pretty straightforward...

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
Re: Re: Re: Re: still having white screens

just to be sure, i unstalled, ran update, re-downloaded the 1.0.tar, reinstalled and as soon as i enable it i get a white screen...i don't get it. the code looks solid to me, it's got to be conflicting with another module is all i can figure...i'll keep on digging and let you know if i figure out what it is.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: Re: Re: Re: still having white screens

Hm... Can you try one more thing for me? Flush your Drupal cache and see if it works. Not sure why it's like that at your side, but it works for me so far. the .tar is the latest version with some fixes. I'm new in ubercart. I'll see if I can remove the .zip file for less confusion.

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 123
issue created

instead of this being out here under the module, i've created an issue for this:
http://www.ubercart.org/project_issue/white_screens_after_enabling

it was hard to find because when you create an issue, there's a project dropdown...when you first choose, it says Chained Attributes, but then under the body of the issue you have to choose project again (what's up with that anyway, UC admin folk?) and it is listed there as "Links attribute options"

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Got past all the bugs but still doesnt work

Hi,

I finally got rid of the white screens and then the 'require_once()' error. But now when I go to Store Admin->CANO it doesn't show any of my products in the CANO definitions tab. I can't add any definitions either the "Select parent attribute:" drop down is empty and the "Select parent attribute's option:" is also blank.

This module has wasted about a day and I'm really frustrated with it. It doesn't say it's alpha or beta so wasn't expecting so much trouble with it. Does anyone have any ideas how to achieve this sort of functionality without using this module?

Any help would be gratefully received!

Thanks

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
bug fixes

can you try this? It should work. if still not, you may consider disable, then uninstall, and then re-enable the module.
if it does work, please let me know and I'll upload as a new release. thanks!

AttachmentSize
uc_cano-1.2.tar 61 KB
oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
White Screens

Hi Robbie,

I enabled it - white screen Sad

I get these errors now:

warning: Cannot modify header information - headers already sent by (output started at /Volumes/FreeAgent/www/stripe21/public_html/sites/all/modules/ubercart/contrib/uc_cano/uc_cano.module:1) in /Volumes/FreeAgent/www/stripe21/public_html/includes/common.inc on line 148.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: White Screens

If I cut and paste all the code into new files then the blank screens go and so does the 'Headers already sent' errors.

I still don't think it's working as the Parent fields are still blank.

AttachmentSize
Picture 45.jpg 91.02 KB
robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: White Screens

Are you using Safari in Mac? Honestly this module is built with Firefox and IE in mind and has been tested in these two browsers only. I'm not sure if this is the reason. Can you switch to Firefox and try again? Thanks!

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: Re: White Screens
oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: White Screens

Yes I was using Safari on Mac. I've uninstalled it and re-installed it using Firefox, get the white screen again when it's enabled and again nothing shows up on the admin side like the previous attached jpg.

Looking the URL you posted - Yes that what I need. I'm trying to do it using Attribute Tokens and Custom Price but it's far from ideal.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Chained Attributes and Options

I've booted up the Windows XP Machine (Virtual Machine under OSX) and uninstalled the CANO module and re-installed using IE and it still does the same thing. Also I tried changing the theme to Garland as I was running Barlow - no difference though.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Re: Chained Attributes and Options

Hm.. Can you post your Drupal and Ubercart versions? If possible, give me your Drupal access and I'll be glad to take a look.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
It's Working

Hi Robbie,

I've download the latest version of Drupal (6.19) and installed afresh with only the ubercart and CANO module installed. The CANO version is where I copy and pasted the contents of the module to new files. I was using Drupal 6.17.

It's working! This is a very useful module and I can see a lot of people in need of something like this. I'm using it with Safari 5.01 with OSX and it's fine so far. I'm going to slowly install the other uber modules I was using and see if any disable CANO. I'll let you know if they do.

One question. Is there a way to force a product to have an option without the user actually having to click on it, when there's only one possible choice?

For example the site I'm working on a user has a choice of contract length and a setup fee. I'm using CANO to figure out which setup fee applies but would like it to be added automatically as they don't have a choice. For a more complete explanation see my post here:

http://www.ubercart.org/forum/support/17884/product_attributesubattribute

Thanks a lot for your help.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: Chained Attributes and Options

I've just seen your post about versions above. Drupal 6.17 and Ubercart 2.3

I'd be happy to zip up the old 6.17 version of the site and email/ftp it to you if you want to investigate further.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: It's Working

Horay! I'd be very interested to know the module(s) that cano conflicts with. Please keep us updated. Thanks!
ps. I'll be in travel for a few days and may not be able to come back as frequently.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Chained Attributes and Options

I've re-installed all the modules and CANO is still working. So I thought the problems I had must have been something to do with Drupal 6.17 so I updgraded the old non-working CANO site to Drupal 6.19 thinking that CANO would work only it didn't. I'm a bit stumped now as to why it works on the fresh install site and doesn't on the upgraded but identicle site.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Attribute Label Submit Bug

I've noticed that sometimes after you've created a new attribute that it doesn't show in the Add Definitions screen. Doing a Performance->Clear Cache also doesn't do anything. What you have to do is go back into the Attribute (Store Config -> Attributes) and Edit the missing Attribute and just click on Submit again. When you go back to the Add Definitions you'll see the Attribute now listed.

It seems something to do with the Label field when creating an attribute. When you initially create an Attribute you only have to enter the Name field and the Label field is automatically populated by Attribute Module/Ubercart/Drupal when the submit button is clicked. If you let Attribute Module/Ubercart/Drupal auto populate the Label field then it won't show up in the CANO Add Definitions screen until you go back and click submit again. However, if, when creating an attribute, you make sure that Label has some text in before you click the Submit button then CANO will see it straight away..

ixlr8's picture
Offline
Joined: 09/28/2008
Juice: 26
Select Boxes vs. Check Boxes

I'm trying to create a product that has multiple options. Rather than having a lot of yes/ no checkboxes, I set up each choice as a checkbox option for the attribute. Some choices have binary options, either yes or no, but some need slightly more info (ie. color choice for a specific option). This module seems like a great choice for me. However, I'm having a few issues:

When an attribute is set up as a checkbox, instead of a drop down, it doesn't show up in the list of available parent attributes.
The children attributes aren't hidden when I load the product node.
I don't see an "edit" link on the CANO overview page to edit a specific definition.

I'm using v. 1.2

I've tried disabling, uninstalling, and reinstalling the module, but I get the same results. I've tried to delete attributes and remake them with no results. I've tried clearing my cache, with no results.

If anyone could offer any advice, it would be appreciated.

Thanks!

Mike

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Attribute Label Submit Bug

oncreative: Yes you're right! You'll have to specify BOTH the attribute name and label when submit the definition. Otherwise it won't show because it considers the label "null". But when you submit it again, it uses the attribute name. I'll try to fix this later. But for now, it works if you keep it in mind.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Hi Mike, as of now,

Hi Mike,

as of now, unfortunately the module is defined to handle dropdown style of attributes. and also, it's developed with ubercart 2.x in mind. and we havn't tested its compatibility with 1.x yet, and we don't have a plan to do so. we'll only continue to port it to feature ubercart versions. I'm sorry....

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Hi oncreative: >>> One

Hi oncreative:
>>> One question. Is there a way to force a product to have an option without the user actually having to click on it, when there's only one possible choice?
yes, uc_cano is designed for this. depending on your default option of that attribute, all you need to do is to define either a Enable or Disable type of dependency.
For example, if on loading your default option of attribute A is No, and in this case you want to disable the dependant attribute B, then you'll need to define this: "No" of Attribute A --> Disable --> Attribute B.

ixlr8's picture
Offline
Joined: 09/28/2008
Juice: 26
Re: Hi Mike, as of now,

Sorry, I don't think I was clear. I am using ubercart 2.x. I was using verson 1.2 of the uc_cano module.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Hi Robbie, Ahhh thanks for

Hi Robbie,

Ahhh thanks for that I wondered what the disable option was all about and hadn't had time to investigate. I'll have a look at that.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Hi, Nope it doesn't work as

Hi,

Nope it doesn't work as I'd expected/hoped as it doesn't do down enough 'levels'. Here's the scenario.

User Selection of Attribute Options A;

- A Option 1
- A Option 2
- A Option 3
- A Option 4

User Selection of Attribute Options B;

- B Option 1 --> Must now be forced to have option C Option 2
- B Option 2 --> Must now be forced to have option D Option 3
- B Option 3
- B Option 4

Attribute Options C;

- C Option 1
- C Option 2
- C Option 3
- C Option 4

Attribute Options D;

- D Option 1
- D Option 2
- D Option 3
- D Option 4

This is more like a feature request than a bug.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Un-selected options in Cart

In order to get around the problem of forcing a user to have one option from a selection I created the final options individually and then created an idividual mapping for each one like this:

User Selection of Attribute Options A ;

- A Option 1 => shows Options B
- A Option 2
- A Option 3
- A Option 4

User Selection of Attribute Options B;

- B Option 1 --> Must now be forced to have option C Option 2
- B Option 2 --> Must now be forced to have option D Option 3
- B Option 3
- B Option 4

I created a single attribute "C" with one option "Option 2" and mapped B Option 1 to it. I did the same for "D Option 3".

So now the User Selects an Option A which pulls up Options B then the user selects B Option 1 which correctly pulls up option "C Option 2".

The problem now is that both "C Option 2" and "D Option 3" are added to the Cart even though option B Option 2 (and by association D Option 3) was not selected by the user.

fehin's picture
Offline
Joined: 12/17/2008
Juice: 154
Re: Chained Attributes and Options

This module sounds like a great idea. I will check it out. Thanks.

aireworth's picture
Offline
Joined: 12/07/2008
Juice: 91
Names rather than Labels for selecting dependant attribute

Hi
Many thanks for the module, helped to solve a problem here.

However I note you're using the attribute label rather than attribute name for selecting dependant attributes in the CANO "Add Definitions" screen. I wanted to have some of my dependant attribute with no label - I had "none" in the lable field. When I then go to select I cannot tell which attributes I am selecting - I get a list of several different "none"s.

Surely it would be better to use the attribute name, which is always going to be unique (I think)?

Colin

aireworth's picture
Offline
Joined: 12/07/2008
Juice: 91
Ver 1.2 fails to update price change from dependant attribute

Hello again

I'm using ver1.1 on my site, but I tried out version 1.2 as in this queue above. It seems to have broken the ability of dependant attributes to alter the checkout price. My dependant attributes are part days on courses, and each has a cost. Under 1.1, this worked well with the cart updating properly. With 1.2 they didn't appear in the checkout pane and their price wasn't added to the checkout price. This was whether the dependant attributes were enabled from above, or disabled from above.

Colin

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
you're right

oncreative:
yes you are right. unfortunately the uc_cano module is not capable to meet your needs out of box. It disables / enables others at attributes level instead of option level.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
aireworth: I checked in my

aireworth:
I checked in my store it seems to be working fine. can you give your attribute and option structure in details here so that I can take a closer look?

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
@aireworth - I'm using

@aireworth

- I'm using Drupal 6.19 and Cano 1.2 and it works fine for me. I noticed a similar thing happening though and went back an saw that the 'relationship defs' were set to disable instead of enable. The CANO default is "disable" - could that be it?

mpkpm's picture
Offline
Joined: 06/07/2010
Juice: 71
Re: Re: It's Working

Hi i am also interested in using this module..however when i enable it i get white screen. after cache clearing also the white screen is coming. it shows a warning
"warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/mysite/sites/all/modules/uc_cano/uc_cano.module:1) in /var/www/mysite/sites/all/modules/remember_me/remember_me.module on line 58."
i am new to drupal,informed you so that you can help in using this module.
I am working on firefox on linux.

oncreative's picture
Offline
Joined: 08/23/2010
Juice: 183
Re: Re: Re: It's Working

Yeah I had this problem. Try copying and pasting all the code into new files with the same names using a text editor like TextWrangler (Mac) or maybe notepad (Windows).

mpkpm's picture
Offline
Joined: 06/07/2010
Juice: 71
Re: Re: Re: Re: It's Working

Thanks @oncreative .. it worked

archer007's picture
Offline
Joined: 09/22/2010
Juice: 30
How do I actually use this module?

This may be a stupid question, but now do I use this module? I don't see any new menu options.

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
Re: Chained Attributes and Options

once you enable the uc_cano module, go to Store Configuration and you'll find it. You can add dependency from there. The module has minimum options/configurations needed other than adding attribute / option dependencies according to your needs.

vizteck's picture
Offline
Joined: 09/23/2010
Juice: 32
Active

We are checking issues one by one.. and fixing. Look out for an updated version in this week

robbie's picture
Offline
Joined: 03/17/2010
Juice: 107
@vizteck: do you think the

@vizteck:

do you think the white screen problem mentioned by users is because of our source code encoding format? The source is currently encoded in UTF-8. Maybe that's the reason?