【问题标题】:Shopify Theme - Discount percentage always at 0 (product page)Shopify 主题 - 折扣百分比始终为 0(产品页面)
【发布时间】:2019-07-22 18:35:39
【问题描述】:

我的产品的折扣百分比始终等于 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>

可以检测到代码有什么问题吗?

最好的问候,

【问题讨论】:

    标签: themes shopify shopify-template


    【解决方案1】:

    在您的 Shopify 后台中,“商店货币”(设置->常规->商店货币->更改格式)下的值似乎与代码中的值不匹配。

    管理员中的值是否以“$”开头?如果是这样,您能否从代码中省略它们。例如。而不是 'if money_pro_format contains "${{amount_no_decimals}}"',使用 'if money_pro_format contains "{{amount_no_decimals}}"'

    【讨论】:

    • 谢谢!这解决了这个问题。我还没有弄清楚的另一件事:如何更改“关闭”表达式?例如,将“您节省了 50%”而不是“50% 折扣”
    • 我认为这可能是在您的翻译文件中设置的,该文件可以在“locales”目录中找到。我希望有一个条目说类似:“products”:{“product”:{“on_save”:“%OFF”}}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-02
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多