Hi,
uc_discounts don't play with attributes for a too long time. This is the lack that divide the most the number of potential users for this module IMHO.
In fact, by analyzing the code, uc_discounts was not designed to play with them, and it needs some core modification to make it able to do it, here is the conclusion of my brainstorming about that.
The original idea to considers items instead of products is good, this allows to registers some ideas, whatever if the idea is a term id, product id, something id. And each submodule can write his code to interpret this idea and return a result.
The problem to deal with attribute is that you need to know the product id, but, you need to know the option id, children of a product id too. That's why the uc_discounts module need to understand a second level in the serialized item data saved in the database. The good news is, as item id don't mean produc id, the attributes id will not be usable only with product submodules, and each submodules will be able to benefit this new level in the item array (or not).
Create a new level for items means some changes :
- Modify the database item structure to make it as text, not as a varchar, cause varchar 256 is too limited for this kind of serialized array
- Modify the uc_discounts_condition_form_submit() and uc_discounts_action_form() to make them understand multidimensional array and save them properly
- Modify all submodules conditions and action apply functions to make them multidimensional array too
- Modify all submodules items name function for the same reasons
- Modify submodules features to take the advantages of attributes when needed, uc_discounts_products for example, to make it properly deal with attributes. In addition, as attributes depend on their parent result we have 2 choices :
- Create a new step for the form (but 3 step is loud to configure)
- Make it via ajax (ahah is drupal 6 core now) this is the right solution in my opinion, you can dynamically choose an attribute without page refresh, it's good !. The problem is that ahah is not drupal 5 core, so it work only on d6 without dependencies... - Maybe more, I'm working on it and I didn't finished yet...
As I said, I'm working on that task, however, it's for drupal 6, so I made the attribute selection via ajax. If you want to make it d5 compatible, you will have to add ahah dependencies or rewrite a part of the code to create a new step for action/condition form.
I will not post code yet because it's not finish, I hope I will be able to post the modified and d6 compatible module this week.