0

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.

Santosh S Kumar
  • 469
  • 1
  • 6
  • 30

1 Answers1

1

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.

hynekcer
  • 14,942
  • 6
  • 61
  • 99
  • thank you that worked. I was already using {{ product|sale_price|currency}} but I am wondering why would {{ product|discount_price:sale|currency }} work in the product.html file... found under product/templates/product.html and not when used in homepage or category page... btw, I did load all the required template tags. – Santosh S Kumar Apr 06 '12 at 16:33
  • thank you for your help, but this worked only to a certain extent... I want to display the actual price strike out for only products which have the discount using if condition like {% if storewide_sale %} or which ever applies then strik out the actual price and show sale price... but this does not seem to happen on featured page. – Santosh S Kumar Apr 06 '12 at 16:56
  • I just achieved this by using `{% if product|discount_saved:storewide_sale %}` can you confirm if this correct way of doing it! Thank you. – Santosh S Kumar Apr 06 '12 at 17:00