| Project: | Ubercart |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I'm using Ubercart for a new D6 site I'm developing, but had the need for a feature that wasn't available. I wanted to introduce the concept of 'dependent attributes'. That is, a product attribute that is only available based on the value of another attribute. An example might help explain:
I'm selling language courses. Each language course is set up as a product in Ubercart and has several attributes that affect it's price. One such attribute is 'Accommodation Option' This could be a Single Room, Double Room or None. In the case of the user selecting a Single or Double Room, another option should be presented to the user, 'Accommodation Length', where the user can specify how long he/she would like the accommodation for.
In the above example, the 'Accommodation Length' attribute could be said to 'depend on' the 'Accommodation Option' attribute. I have written a module which lets you introduce attribute dependencies. Whilst at present it only offers rather basic functionality, it does function well for my needs and I'm sure other people would find a use for it so I would like to release it to the community.
Currently the module lets you choose one other attribute that the attribute depends on. It also lets you specify a list of attribute options that count as a null selection. In the example above, I entered the attribute option id (oid) of the 'None' value. When the user selects one of these null_values on the dependency, the dependent attribute is disabled with AJAX
Things to do before an official release can be made:
- Update/override form validation handler based on attribute visibility/presence
Possible extensions are:
- Ability to choose more than 1 dependency
- Ability to override dependencies at the product class and product levels
- Provide a nicer way of specifying the null_values (multiple select box? auto complete text area?)
- Allow users to choose if form elements should be disabled or completely removed
- Allow users to specify a default value for when elements are just disabled rather than removed.
Questions:
- What do you think of the idea?
- Has it already been implemented elsewhere?
- Would anybody be willing to help out with this module?
- If I release it as a contributed module, what do you think for a name? Currently I have it as uc_aad - Uberart Ajax Attribute Dependencies. I'm not sure about including AJAX and was thinking about uc_attribute_dependencies instead...
Comments
#1
Edit:
Things to do before an official release can be made:
- Update/override form validation handler based on attribute visibility/presence#2
If I've understood correctly this sounds similar to Hierarchical Select to me. Have a read of: http://www.ubercart.org/forum/development/5335/hierarchical_select_uberc...
#3
No, not really. I know about and use the Hierarchial Select module already. That module simply give you a nice AJAX way of browsing tree like structures and making selections from them (taxonomy for example). What I have done here is set up a dependency for an Ubercart product attribute. Which makes the attribute in question only required (or even available) if it's 'parent' attribute has been selected with a certain value.
#4
I don't know what's been done towards this issue, but I know that I won't get to it until we start working on the 3.x version. If someone has an update in a different direction, they are welcome to take over this issue.
#5
mrfelton: Just reading this for the first time today. This "dependant attributes" is exactly what I need. Where are you with your project, are you close to a contributed module on this?
Also, I'm running 5.x, and realize you're on D6.
#6
Well, I use what I have on a live site. However, I didn't really peruse much further (as in, create an actual contributed module) it as it sounded like this was something that would be implemented in the future, but in a more complete way that I went about it. You are welcome to my code if you like, but it is Drupal 6 only and I have no intention on backporting it. That said, if you think it is useful, and feel that other s would too, AND you are willing to backport and maintain a Drupal 5 version, then I would consider creating an official project out of it.
The code is attached. I haven't actually touched this code for a while, but as I say, I use it on a live D6 ubercart site without issue (although I haven't updated ubercart to the latest -dev code on that site for over a month now, so things may have changed)
EDIT: For an example of it in use, see: http://www.geminicourses.com/courses/bristol-school-language-project-gen.... Select an accommodation option, and you should see a new option appear below it.
#7
Thanks but I can't open the file in your attachment: it seems to be a binary file. Could you attach the file in ASCII? Thanks.
Your site looks great. I'm looking forward to backporting this to D5. An official project would make sense I think but let's address this after I implement the D5 port.
#8
Ok I was able to unpack your files after all. No need to resend them. I will look into this, thanks again.
#9
I'm hoping to have a chance to look at this fairly soon. Do you have a newer version? If so please send. Thanks.
#10
no, what I have there is the latest. I haven't worked on the site that uses this for a while.
#11
This is a good idea and partly what I'm looking for. I'm looking for something like 'grouped' attributes.
Imagine a clothing store where certain garments are available in certain sizes and colours, but the colours vary depending on those sizes. Eg, the full list of options for a shirt might be:
Small, Red
Medium, Red
Medium, Blue
Large, Blue
Now, I know you are thinking that these could be created as 4 different attributes but that doesn't work if a user wants to search for all the 'medium' shirts available. To perform proper searching the attributes would have to be separate.
However, in the example, some sort of dependency or grouping would need enforcing to say for this product if the user chooses 'Small' they must choose 'Red'. If they choose 'Large' they must choose 'Blue'.
Does that make sense and do you think this is possible?
#12
I agree with raintonnr! Please implement this as we need it :-)
#13
I have introduced a new Dependent Attributes module. You can find the project at http://drupal.org/project/uc_dependent_attributes. There will be a development snapshot available within the next 24 hours. This module accomplishes what is requested in #11 and #12. I need testers so please download the snapshot as soon as it is available and begin testing.
Cheers,
Antoine
#14
#4 indicated that this was being postponed until 3.x. Now that the 7.x-3.x branch exists this issue can be reopened for consideration.
#15
mrfelton,
I have looked all over the drupal and ubercart forums and you have explained the exact functionality that I require. I have tried installing uc-aac and the Dependant Attributes module and I can't seem to get my head around how to set it up for my purposes.
I installed the primitive uc_aad module you posted in this thread a few years ago and it seems to do EXACTLY what I am looking for (on the administration side of things anyway).
In the store I am making, I have a book that is for sale. The store is on the website representing the book's Author. This book is available from national (Canada) retailers, but we also sell it on our online store. On our store the book is sold as Autographed. All books sold from our online store will be autographed in some way. However, the customer can choose an "Autograph Type" which specifies whether they have a "Standard Autograph" or a "Personalized Message & Autograph". If the customer chooses the "Personal Message & Autograph" option I want a separate textfield attribute called "Message Details" to be displayed so the user can enter in their desired message details.
Using your simplistic module provided I can create the "Message Details" attribute and assign it as a dependent of the "Autograph Type" attribute. Next I wanted to assign the "Standard Autograph" option as a NULL value in the dependency settings but it doesn't seem to work. I believe I have narrowed down the oid of the NULL value, but it doesn't seem to matter - any value I enter does not effect the visibility of the "Message Details" attribute.
I hope you are still able to receive information on this thread and can help me is setting this up as you have on your demonstration site. If not, has anyone else been able to get similar functionality working on their site - using ANY module(s) - and can help a little to get me setup to do this...
Please advise...
#16
Hey,
I'm also in the middle of trying to hunt down a solution for this. I haven't tried the two modules outlined here yet, but if anyone knows of any better solutions let me know. If the two modules above don't work out I'll be rolling my own.
Cheers,
Gene Bernier
#17
subscribing.
Need a personalization solution.
Still looking, if anyone knows of one please post. Thanks.
#18
I ended up building my own solution for the customers needs using AHAH Helper, Taxonomy and the following Ubercart hooks: hook_add_to_cart_data, hook_cart_item and hook_product_description.
It's worked out pretty well, if you are interested I can share it with you.
#19
Thanks, I found out I needed a much less complex solution, just needed to limit the length of text fields and this module seems to do that.
http://drupal.org/project/uc_attribute_length
#20
Are dependent attributes going to implemented in Ubercart 3.x?
I am using Ubercart 3.x and I do not know whether I should wait for it to be implemented or I should start writing a contributed module. Thanks
#21
I started writing my new module http://drupal.org/node/1172426