【问题标题】:In satchmo, How to display price in featured products, home page and category page of products在satchmo中,如何在特色产品、产品首页和分类页面中显​​示价格
【发布时间】:2012-04-06 14:48:02
【问题描述】:

我用过

{% if sale %}
    <strike id="fullprice" style="display: block;">
        {{ product|discount_price:""|currency }}
    </strike>
{% endif %}
<span id="price">{{ product|discount_price:sale|currency }}</span>

这在没有 sale 的情况下有效,即 discount_price:sale|currency 并引发异常

渲染时捕获 VariableDoesNotExist:查找键失败 [销售] ...

同时显示销售价格和非销售价格很重要。我怎样才能做到这一点。

【问题讨论】:

    标签: satchmo


    【解决方案1】:

    如果您使用按产品分配的单独销售,您应该使用

    {{ product|sale_price|currency }}
    

    或者你可以用taxed_sale_priceuntaxed_sale_price替换sale_price,如果你想设置一个明确的,例如在发票上。

    如果您指的是整个网站的折扣,例如要为登录用户创建特殊折扣,您应该使用 discount_price:storewide_sale 因为上下文处理器创建的这个“sale”变量已根据多个用户的请求重命名为 storewide_sale。

    【讨论】:

    • 谢谢你的工作。我已经在使用 {{ product|sale_price|currency}} 但我想知道为什么 {{ product|discount_price:sale|currency }} 会在 product.html 文件中工作......在 product/templates/product.html 和不是在主页或类别页面中使用时...顺便说一句,我确实加载了所有必需的模板标签。
    • 感谢您的帮助,但这仅在一定程度上起作用...我想仅显示使用 if 条件(如 {% if storewide_sale %)有折扣的产品的实际价格删除} 或适用的然后删除实际价格并显示销售价格......但这似乎不会发生在特色页面上。
    • 我刚刚通过使用{% if product|discount_saved:storewide_sale %} 实现了这一点,您能否确认这种方法是否正确!谢谢。
    猜你喜欢
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多