Jump to:
| Project: | UC Discounts |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi all,
This thread is the following of a discussions about module improvement and port to 6.x.
I created this thread to discuss about discounts are actually managed, and, how it should be in a perfect world.
Today, the uc_discounts calculate some actions depending on some conditions, I learn that fact to nobody. If you deeper analyze the code, you can see that the module return the discounted value for a product. So it return a number.
In an order level, it return an array of applied discount with their respective values.
Instead of returning a single discounted values for products, I asking myself if it would not be better to associate a discount object to $node, when a discount apply to a node. For the same reasons ubercart added an attributes object to a node (see the discussion here). It is more in-line with the node philosophy and it would allow others modules to easily alter the discount object.
I didn't work on it yet, I would like to know opinions of different people to know if it's the way to go, I think it would be a great addition, I don't know yet why module would alter the discount object, but I know it would be cool to allow it.
Comments
#1
I worked on that and here is the result :
Instead of a single discounted price, the uc_discounts_product_discount_price() have to return an array of all discounts that apply to a product. Like that, it will be simplier to add extra informations to a discount when we will want to add extra features. And all discount informations will be centralized in a single array.
Like that, you can associate this array into the node object using the hook_nodeapi() and you will automatically get the discounts informations when loading the node object.
So, instead of having a $node->discounted_price (float), we have a $node->discounts (array).
Note that instead of returning the full discounted product price, the function return the discount amount, and the discount amount is substracted to the node->sell_price on the hook_nodeapi.
#2
comitted to 6.x branch
#3
Automatically closed -- issue fixed for two weeks with no activity.