【问题标题】:Money filter giving worng asnwer in calculations liquid shopify货币过滤器在计算液体 shopify 中给出错误答案
【发布时间】:2021-05-08 07:58:13
【问题描述】:

我正在尝试显示我的产品打折后的金额。计算效果很好

例如,我的总价是 500,折扣是 50%,我得到的答案是 250,这是正确的,但是当我使用货币过滤器显示货币单位时,即(Rs.)它给出的错误答案是 Rs。 3

                                My code that gives correct output but without currency unit


    {% assign percent_calculated = section.settings.custom_discount_title  | times: productprice  | divided_by: 100  %}
        
  <span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo"   style="color:#FFDAB9" >{{ productprice  |minus : percent_calculated }} </span></div>


                             OUTPUT
250 

我想将其显示为卢比。 250 但为了实现这一点,我使用“|money”过滤器并得到错误的答案

{% assign percent_calculated = section.settings.custom_discount_title  | times: productprice  | divided_by: 100  %}
            
      <span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo"   style="color:#FFDAB9" >{{ productprice  |minus : percent_calculated | money }} </span></div>

                                               OUTPUT 

卢比。 3(答案应该是 250 卢比)

【问题讨论】:

  • 听起来好像是 2.50,所以如果你除以 100,那么你需要在应用货币过滤器之前将它乘以 100。
  • 我得到了我之前使用 money_without_currency 的解决方案

标签: shopify liquid


【解决方案1】:

我得到了删除 money_without_currency 过滤器的解决方案 我使用它是因为我很困惑液体语言需要数据类型转换,我之前使用过它。

【讨论】:

    猜你喜欢
    • 2017-04-29
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-26
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    相关资源
    最近更新 更多