Developer forum

Forum » Feature requests » Attach discount rules to stock locations

Attach discount rules to stock locations

Arnór Halldórsson
Arnór Halldórsson
Reply

Hi guys,

One of our customer has differing discounts between his multiple stores.

We would like to be able to sync those discount rules over to Dynamicweb, both in order to improve performance on product list pages as well as being able to use them in displaying certain product lists (show only products on specific discounts / campaigns).

We have all their stores synced over as StockLocations in Dynamicweb, but there´s no way to bind a discount to a specific stock location. Is this something that you would considder adding to Dynamicweb, or is this something that I can do myself via custom discount extender?

Best regards,
Arnór


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Arnor

It is currently not an option as default.

But you can create a DiscountExtender to make the decision based on the stock location - see examples here:

https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.Orders.Discounts.DiscountExtenderBase.html

You need to return true or false on the DiscountValidForProduct method depending on the stocklocation. Since that method is passed a product, you have to look up the current stock location from context - maybe using Dynamicweb.Common.Context or alternative measures. There will be a difference what that context is depending on if you are coming from the webapi or the regular frontend.

BR Nicolai

 
Arnór Halldórsson
Arnór Halldórsson
Reply

Thank you sensei, I'll try it out :)