Developer forum

Forum » Templates » Only show @Ecom:Product.Discount.Price when there is a discount

Only show @Ecom:Product.Discount.Price when there is a discount


Reply
How do I make a template for a product, with specific elements that only shows on discounted products?

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
There are a few ways of doing this. The elaborate way and the quick and dirty way.

The elaborate way includes you creating a ProductTemplateExtender. Checking for whether a product has any discounts set. If so, then render a tag indicating this. In your template you simply check for this tag and show your element if the tag is set.

The quick and dirty way is to just use JS to check the value of the discount. If it's set and is greater than 0, then show your element.

Another way is to use XSLT templates. There you can make your check in the XSLT and only do the apply-template that creates the element if the value says that a discount is present.

- Jeppe
 
Nicolai Høeg Pedersen
Reply

I've added this to be fixed in 7.2 - if there is a discount you will have a new template tag that returns true if the product has a discount.

 

You must be logged in to post in the forum