Active
Project:
UC Discounts
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Oct 2008 at 08:39 UTC
Updated:
28 Oct 2008 at 07:30 UTC
Hi,
This thread is the following of a discussions about module improvement and port to 6.x.
the uc_discounts module allow to show a discounted price on a product level, however, this feature is not made in a "clean" way and need some improvements I think :
These 2 things will be included in the 6.x package I will release soon.
Comments
Comment #1
zmove commentedHi again,
I would bring more precisions about the discount calculation.
I only worked on uc_discounts_products and uc_discounts_users modules because I only need these 2 ones for my shop at the moment and I forgot to take care of the uc_discounts_order_total module. I understand better now why the product function seems to be a modified copy of the order function. I think uc_discounts was originally written to allow discounts on order total, and then modified to work on products.
But, even if understand better the origin and the logic of that 2 functions, I continue to think that it's a "dirty" way to implement it. Single products are not cart and we need dedicated functions to deal in a product level and dedicated functions to deal in order level.
For me, the best way to do that is to differentiate 2 callback apply functions, to not be obliged to pass a fake cart and fake variables to deal with discounts in a node level. we could have hook_apply_order for submodules that need to deal in an order level only and hook_apply_node for submodules that need to deal in a node level.
Providing these 2 hooks in submodules themselves would allow to pass right parameters to each callback, without the need to create fake variables, and it would allow for submodules creators to have a better control of what their submodules do. If somebody want to deal only in a order level, he could create only a hook_apply_order function that will even not be loaded on node_load.
Comment #2
zmove commentedI would like to add a last thing, a question :
Is is useful to let users to choose an option like "when the discount apply" ?
For me it is a useless option and it bring limitations, why ?
This is a reason why I think the behavior to apply a discount should be defined in a submodule level, and not in the "master" level, because it's highly dependent on the "things" you want to discount. That's why the idea of 2 different callback...
Comment #3
joachim commented> Is is useful to let users to choose an option like "when the discount apply" ?
Yes, I've been wondering this too. We should open another issue to discuss this.
Regarding the two fixes this issue is about: $op switch and fake cart -- can you do a patch or a snippet of your code so we can get this into 5?
Rather than your D6 version being a huge lump of code we have to assimilate, I'd like to make a smooth transition between 5 and 6: get as many things as we can into both the 5 and 6 branches.
Comment #4
zmove commentedHi,
As this change is not related to menu, form or other, I think it will can adapt quite easily to 5.x.
I didn't finished this part of the code, but it's possible that submodules needs some changes too, I will post code for submodules I modified too.
For the option like "when the discount apply", are you really happy with it like that ?
For me, the order apply discount option is useful only for discount on order total. If you choose this option and apply a discount on a product, the display price of the product is the discounted product price, when you add it to the cart, you have the full price. It's a non-sense that can easily confuse your visitors.
But, if you choose to apply a discount when a product is added to the cart, when you create a discount on order total, you don't want to see product discounted into the cart, you only want your discount appear on the checkout page. That's why I think this option should be managed in a submodule level, because the behavior you want highly depend on the discount you create.