In satchmo, How to display price in featured products, home page and category page of products

StackOverflow https://stackoverflow.com/questions/10045117

  •  29-05-2021
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top