I used
{% if sale %}
<strike id="fullprice" style="display: block;">
{{ product|discount_price:""|currency }}
</strike>
{% endif %}
<span id="price">{{ product|discount_price:sale|currency }}</span>
This works without sale i.e., discount_price:sale|currency and throws an exception
Caught VariableDoesNotExist while rendering: Failed lookup for key [sale] in ...
Its important that both sale price and non sale price is displayed. How can I achieve this.
If you use individual sale assigned by product, you should use
{{ product|sale_price|currency }}
or you can replace sale_price
by taxed_sale_price
or untaxed_sale_price
if you want set one explicit e.g. on invoices.
If you mean a discount for whole site, e.g. to create a special discount for the logged user, you should use
discount_price:storewide_sale
because this "sale" variable created by context processor has been renamed to storewide_sale at the request of several users.