We have a customer voucher discount, which in our code loops though the orderlines and adds those to determine the maximum discount to give without resulting in a negative order price.
Example
discount: 120 euro
product 1: 20 euro
product 2: 30 euro
shipping : 5 euro
Our discount providers calculates the discount price as 55 euro.
So the order looks like:
product 1: 20 euro
product 2: 30 euro
shipping : 5 euro
discount : 55 euro
total order: 0 euro
Now if we active an additional discount, like 10 euro discount on product 1 we get:
product 1: 20 euro
product 2: 30 euro
shipping : 5 euro
discount : 55 euro
discount : 10 euro
total order: -10 euro
In the discount provider we already loop though the orderlines, however the discount order lines are not available.
Probably because discounts are handled after the providers have triggered to ensure correct behavior.
However it seems necessary to be able to retrieve the discounts that apply on the order in the discount provider so we can make sure the discount we give is never more then the total order amount.
Developer forum
E-mail notifications
Retrieve discounts in a discount provider
Edwin van der Velden
Posted on 04/10/2011 15:15:22
Replies
Nicolai Høeg Pedersen
Posted on 04/10/2011 15:57:32
You have an order with orderlines. Whenever it changes, we discard all discounts and look for discount providers and apply them again based on how the order looks now.
Since you are making a Discount provider, which is one of many possible providers, the system cannot at that time give you all the discounts - as your provider is one of them... It could be number 2 of 4 being applied. So your discount cannot be dependent on other discount providers as it would create a possible cirkular reference.
Hope that makes sense?
So - to achieve what you are doing, you have to apply all the discounts in one provider - giving you the ability to make rules on which should be applied and which should not...
Since you are making a Discount provider, which is one of many possible providers, the system cannot at that time give you all the discounts - as your provider is one of them... It could be number 2 of 4 being applied. So your discount cannot be dependent on other discount providers as it would create a possible cirkular reference.
Hope that makes sense?
So - to achieve what you are doing, you have to apply all the discounts in one provider - giving you the ability to make rules on which should be applied and which should not...
Edwin van der Velden
Posted on 05/10/2011 10:33:56
Nicolai,
Yes it makes sense, but I think it's not entirely true.
I think it would be relatively simple to add something like a priority to discounts, so you know in which order they are to be processed. That way you'll know in which order to precoess and which discount is dependant on another.
Besides that it would be perfectly possible to create one discount that is dependent upon the other discounts, but for that to work you'd need to be able to retrieve all applied discounts.
Creating a single discount which can combine all the discount types sounds a bit like rebuilding all the DW default discounts, I don't think that should be the intention of a CMS...
Nicolai Høeg Pedersen
Posted on 05/10/2011 11:05:21
This post has been marked as an answer
Hi Edwin.
The request have been noted.
It could be a notification that is broadcastet after all discounts have been found and calculated, but before they are applied to the actual order and orderlines.
The request have been noted.
It could be a notification that is broadcastet after all discounts have been found and calculated, but before they are applied to the actual order and orderlines.
Votes for this answer: 0