Shopify 主题 - 折扣百分比始终为 0(产品页面)
Shopify Theme - Discount percentage always at 0 (product page)
我的产品的折扣百分比始终等于 0%
我上传的新商店主题出现了这个问题
请检查合并后的图片:
https://image.noelshack.com/fichiers/2019/30/1/1563820267-capture.png)
我已经尝试检查 product-template.liquid 文件中的代码,但没有发现任何错误。
这是负责生成此折扣的代码部分
<span class="save_discount_pro">
{% if current_variant.compare_at_price > current_variant.price %}
{% if settings.show_discount_amount == 'percent_save' %}
<span class="per_discount">
{% comment %}
{% endcomment %}
{% assign money_pro_format = shop.money_format | strip_html | json %}
{% if money_pro_format contains "${{amount_no_decimals}}" or money_pro_format contains "${{amount_no_decimals_with_comma_separator}}" %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | times: 100 | money_without_currency | replace:",","." | replace: '.0', '' }}{{ 'products.product.on_save' | t }}
{% elsif money_pro_format contains "${{amount_with_comma_separator}}" %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | replace:",","." | times: 100 | replace: '.0', '' }}{{ 'products.product.on_save' | t }}
{% else %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | times: 100 | replace: '.0', ''}}{{ 'products.product.on_save' | t }}
{% endif %}
</span>
能检测出代码有什么问题吗?
此致,
您的 Shopify 后台中的 'Store Currency'(设置->常规->商店货币->更改格式)下的值似乎与您代码中的值不匹配。
您管理员中的值是否以“$”开头?如果是这样,你能从你的代码中省略它们吗?例如。使用 'if money_pro_format contains "{{amount_no_decimals}}"'
而不是 'if money_pro_format contains "${{amount_no_decimals}}"'
我的产品的折扣百分比始终等于 0%
我上传的新商店主题出现了这个问题
请检查合并后的图片: https://image.noelshack.com/fichiers/2019/30/1/1563820267-capture.png)
我已经尝试检查 product-template.liquid 文件中的代码,但没有发现任何错误。
这是负责生成此折扣的代码部分
<span class="save_discount_pro">
{% if current_variant.compare_at_price > current_variant.price %}
{% if settings.show_discount_amount == 'percent_save' %}
<span class="per_discount">
{% comment %}
{% endcomment %}
{% assign money_pro_format = shop.money_format | strip_html | json %}
{% if money_pro_format contains "${{amount_no_decimals}}" or money_pro_format contains "${{amount_no_decimals_with_comma_separator}}" %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | times: 100 | money_without_currency | replace:",","." | replace: '.0', '' }}{{ 'products.product.on_save' | t }}
{% elsif money_pro_format contains "${{amount_with_comma_separator}}" %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | replace:",","." | times: 100 | replace: '.0', '' }}{{ 'products.product.on_save' | t }}
{% else %}
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | times: 100 | replace: '.0', ''}}{{ 'products.product.on_save' | t }}
{% endif %}
</span>
能检测出代码有什么问题吗?
此致,
您的 Shopify 后台中的 'Store Currency'(设置->常规->商店货币->更改格式)下的值似乎与您代码中的值不匹配。
您管理员中的值是否以“$”开头?如果是这样,你能从你的代码中省略它们吗?例如。使用 'if money_pro_format contains "{{amount_no_decimals}}"'
而不是 'if money_pro_format contains "${{amount_no_decimals}}"'