在特定位置的产品页面上显示变体价格
Show variants prices on product page in specific place
我的商店有 10 种产品。
其中一个是杂志订阅,有 3 个变体:6 个月、1 年和 2 年
我使用自定义模板制作了产品页面,并使用简单的 html 插入价格,如下所示:
Price: 25 $ and so on for the other variants...
现在我正在做一些促销,所以我想更新价格而不必在主题中更改它,我正在尝试类似的方法来使其工作但没有成功:
{% 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:我也试过用assign和split做一些其他的实验,我已经成功打印了每个变体的价格,但之后我不知道如何显示价格如我所愿。
遍历每个产品的变体并输出价格:
{% for variant in product.variants %}
{{ variant.price | money }}
{% endfor %}
... 或使用其索引分别输出每个:
{{ product.variants[0].price | money }}
{{ product.variants[1].price | money }}
{{ product.variants[2].price | money }}
[索引从零开始]
我的商店有 10 种产品。
其中一个是杂志订阅,有 3 个变体:6 个月、1 年和 2 年
我使用自定义模板制作了产品页面,并使用简单的 html 插入价格,如下所示:
Price: 25 $ and so on for the other variants...
现在我正在做一些促销,所以我想更新价格而不必在主题中更改它,我正在尝试类似的方法来使其工作但没有成功:
{% 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:我也试过用assign和split做一些其他的实验,我已经成功打印了每个变体的价格,但之后我不知道如何显示价格如我所愿。
遍历每个产品的变体并输出价格:
{% for variant in product.variants %}
{{ variant.price | money }}
{% endfor %}
... 或使用其索引分别输出每个:
{{ product.variants[0].price | money }}
{{ product.variants[1].price | money }}
{{ product.variants[2].price | money }}
[索引从零开始]