Developer forum

Forum » Ecommerce - Standard features » Showing discounts in a banner

Showing discounts in a banner

Jonas Krarup Dam
Reply

Hi,

Is there a standard way to show discounts in the frontend, without it being an actual product list/product detail page?

We have a customer that would like a simple banner at the top of the page, which shows a random discounted product, like "get product xx with a 100kr discount - click here" .

I'm not sure if it would make sense to do this by going through product discounts, and pulling data from those, or if it would make more sense to create a product catalog with only discounted products, and pick from that at random. 

Any suggestions for the best/simplest way to implement this?

Thanks, Jonas


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jonas

There is no super simple way. Discounts comes in 2 flavors - for products and for orders.

Product discounts are applied before you add to the cart and affects the price displayed to the user on the detail page etc - order discounts are applied to the cart and the discount is applied to the order total.

It seems like you need to display products with a product discount. In DW that is not super simple because all kinds of rules can apply to that discount - i.e. is it the right user, the right date, the right country, language and a range of other things. This is the reason why these discounts are not indexed on the products - that could have been nice.

That is to tell that it is very difficult to create something that can give you all products with a specific discount because of the number of rules and products that could cause heavy performance problems.

So, enough for all the excuses...

What you can do is to create some kind of simple setup that allows you to do something. I.e. create a group called "Promoted discounted products" and add products to that group and when they are there, they can be displayed in a banner or similar.

You might also be able to get information from the DiscountService to find the discount them selves:

Will give you all product discounts:
Dynamicweb.Ecommerce.Services.Discounts.GetActiveOrderLineDiscounts();
 
Can give you product discounts for a product:
Dynamicweb.Ecommerce.Services.Discounts.GetApplicableDiscountsForProduct("prod1", "vo1", "lang1", Dynamicweb.Ecommerce.Common.Context.Currency, null);

Both methods are cached and should perform nicely.

BR Nicolai

Votes for this answer: 1
 
Jonas Krarup Dam
Reply

Thank you Nicolai.

I think in this case it makes the most sense to run through the discounts, and show specific ones (right shop,type) :-)

 

 

/Jonas

 

You must be logged in to post in the forum