【问题标题】:Show variants prices on product page in specific place在特定位置的产品页面上显示变体价格
【发布时间】:2019-10-31 17:44:36
【问题描述】:

我的商店有 10 种产品。

其中一个是杂志订阅,有 3 种变体:6 个月、1 年和 2 年

 

我使用自定义模板制作了产品页面,并使用简单的 html 插入了价格,如下所示:

价格:25 美元,其他款式以此类推...

现在我正在做一些促销,所以我想更新价格而不必在主题中更改它,我正在尝试类似的方法来使其工作但没有成功:

{% assign semestraleid = '18773651783776' %}{% variant.id == semestraleid %} {{ current_variant.price | money }} {% if current_variant.compare_at_price > current_variant.price %} <s style="color: #B8DAEE; font-size: 0.85em;">{{ current_variant.compare_at_price | money }}</s> {% endif %} {% endif %}

所以问题来了:如何在这个单页产品页面中显示每个变体的真实价格,以及代码片段的确切位置?

 

谢谢

PS:我还尝试使用分配和拆分进行其他一些实验,我已经成功打印了每个变体的价格,但之后我不知道如何正确显示价格像。

【问题讨论】:

    标签: shopify liquid shopify-template


    【解决方案1】:

    遍历产品的每个变体并输出价格:

    {% for variant in product.variants %}
        {{ variant.price | money }}
    {% endfor %}
    

    ...或使用索引分别输出每个:

    {{ product.variants[0].price | money }}
    {{ product.variants[1].price | money }}
    {{ product.variants[2].price | money }}
    

    [索引从零开始]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-28
      • 2018-07-03
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-13
      相关资源
      最近更新 更多