Shopify函数,用于显示销售百分比';行不通

Shopify函数,用于显示销售百分比';行不通,shopify,Shopify,我有一个函数,它应该显示价格下降了多少%,但却显示了-0% 到目前为止,我得到的是这个 {% if settings.use_saleoff and variant_tmp.compare_at_price > variant_tmp.price %} <span>{{'products.product.sale' | t}}</span> <span class="price_percentage">-{{ variant_tmp.co

我有一个函数,它应该显示价格下降了多少%,但却显示了
-0%

到目前为止,我得到的是这个

{% if settings.use_saleoff and variant_tmp.compare_at_price > variant_tmp.price %}
    <span>{{'products.product.sale' | t}}</span>
    <span class="price_percentage">-{{ variant_tmp.compare_at_price | minus: variant_tmp.price | times: 100.0 | divided_by: variant_tmp.compare_at_price | money_without_currency | times: 100 | remove: '.0'}}%</span>
{% endif %}
{%if settings.use_saleoff和variant_tmp.compare_at_price>variant_tmp.price%}
{{'products.product.sale'{'t}
-{variant_tmp.compare_at_price |减:variant_tmp.price |倍:100.0 |除以:variant_tmp.compare_at|price |货币|倍:100 |删除:'.0'}%
{%endif%}
你知道这里怎么了吗

以下是正确的方法:

{% if settings.use_saleoff and variant_tmp.compare_at_price > variant_tmp.price %}
    <span>{{'products.product.sale' | t}}</span>
    <span class="price_percentage">{{ 1.00 | times: variant_tmp.price | divided_by: variant_tmp.compare_at_price | times: 100 | round | minus: 100 }}%</span>
{% endif %}
{%if settings.use_saleoff和variant_tmp.compare_at_price>variant_tmp.price%}
{{'products.product.sale'{'t}
{{1.00 |次:变量|价格|除以:变量|价格|比较|次:100 |轮|减:100}
{%endif%}
在第一点,您必须显示数字将有小数点

此外,您还有没有货币的
money\u
,这将添加类似这样的
$100 USD
,然后字母将打破数学逻辑。

以下是正确的方法:

{% if settings.use_saleoff and variant_tmp.compare_at_price > variant_tmp.price %}
    <span>{{'products.product.sale' | t}}</span>
    <span class="price_percentage">{{ 1.00 | times: variant_tmp.price | divided_by: variant_tmp.compare_at_price | times: 100 | round | minus: 100 }}%</span>
{% endif %}
{%if settings.use_saleoff和variant_tmp.compare_at_price>variant_tmp.price%}
{{'products.product.sale'{'t}
{{1.00 |次:变量|价格|除以:变量|价格|比较|次:100 |轮|减:100}
{%endif%}
在第一点,您必须显示数字将有小数点

另外,你有没有货币的
money\u
,这会增加像这样的
$100 USD
,字母会打破数学逻辑