Developer forum

Forum » Development » Avoid double discount and discountexternder question

Avoid double discount and discountexternder question

Jan Sangill
Reply

Hi,

I have a customer who have this setup:

1) Prices imported for dealers. When logged in they may have a price added via prices on a product where the price and customernumber fits
2)  Discounts added for special campaigns via product discounts

What I need to achieve is to always show the cheapest price and use this for the customer. If the discountforproducts is the cheapest - they should get this price. If however the price added via prices on a aproduct is the cheapest - this should be their price.

If I via my discountextender allosws the discount - it will be applied to the already discounted price - thus they have double discount.

How could one ahieve this - so if a discount is infact the cheapest - then use the price via (DefaultPrice - discount).

Any ideas are welcome. Let me know if I explained this well enough.


Replies

 
Nicolai Pedersen
Reply

Yes!

 
Jan Sangill
Reply

I pressed enter to fast!:) I have written it now:)

 
Jan Sangill
Reply

bump! Hope someone can help here:S

 
Nicolai Pedersen
Reply

Hi Jan

If a product has a default price of 100 and you put in a price of 90 for customer a, and customer a logs in, 90 is returned. THEN it is passed to the discounts which is then added - i.e. 15% of 90 or 100. In this case the 90 is already found, and you cannot change that fact from the discount. You can only return true or false wether the discount should be applied. In this case, 15% off 100 is less than 90 and returning true or false will not fix that for you. Because you want to change the base price and the discount in one go depending on situation

What you can do, is in IsValidForProduct you can look at the DbPrice property of the product and that would get you the default price of 100. But that will not help you much in this case.

You would have to create a price provider that will return 100 or 90 depending on available discounts for a given product. Finding the discounts here, is the difficult part.

When creating the priceprovider you can call default priceprovider to get the Dynamicweb calculated price and then make the decission if you should return original price or customer specific price depending on the discount will be high enough for the default price with discount is lower than the customer price.

And then you need to also return false in validforproduct if the customer price has been given...

 
Jan Sangill
Reply

Hi Nicolai,

Ty for the response. I will have a look at this.

In your opinion - if I tried implementing this - would this cause the site to be much slower when fetching productlists and so on?

 
Nicolai Pedersen
Reply

Hi Jan

No, it should be doable. You will do the same math on cached items, so as long as you keep an eye on expensive calls, like db access, it should be feasible to get performing.

 

You must be logged in to post in the forum