Shopify首个主题-在特色系列主页上显示最大变型价格
默认情况下,首秀主题显示最低的变体价格。我想在主页和收藏页面上显示收藏特色产品的最大变型价格。通过编辑product-price.liquid代码,我可以在单个产品页面上更改它,但在收集网格上没有任何更改。网址是 我更改了一行代码,但它只更改了产品页面Shopify首个主题-在特色系列主页上显示最大变型价格,shopify,liquid,Shopify,Liquid,默认情况下,首秀主题显示最低的变体价格。我想在主页和收藏页面上显示收藏特色产品的最大变型价格。通过编辑product-price.liquid代码,我可以在单个产品页面上更改它,但在收集网格上没有任何更改。网址是 我更改了一行代码,但它只更改了产品页面 {%- assign price = product.price_max -%} 主题似乎是根据传递到主题的产品价格片段中的单个变量显示价格。更新内容以显示产品的最高价格需要更多的编码 以下是两种方法: 从变体列表中选择价格最高的变体,并将其用
{%- assign price = product.price_max -%}
主题似乎是根据传递到主题的
产品价格
片段中的单个变量显示价格。更新内容以显示产品的最高价格需要更多的编码
以下是两种方法:
特色产品中的当前\u变体
产品价格
代码段中的最高价变体
snippets
文件夹中创建一个新文件,并给它起一个吸引人的名字
使用现有的产品价格
文件作为模板,我们可能会得到如下结果:
{%- assign money_price = price | money -%}
<dl class="price{% if available and compare_at_price > price %} price--on-sale{% endif %}" data-price>
{% if section.settings.show_vendor %}
<div class="price__vendor">
<dt>
<span class="visually-hidden">{{ 'products.product.vendor' | t }}</span>
</dt>
<dd>
{{ product.vendor }}
</dd>
</div>
{% endif %}
<div class="price__regular">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.regular_price' | t }}</span>
</dt>
<dd>
{% if available %}
{% if compare_at_price > price %}
<s class="price-item price-item--regular" data-regular-price>
{{ compare_at_price | money }}
</s>
{% else %}
<span class="price-item price-item--regular" data-regular-price>
{{ money_price }}
</span>
{% endif %}
{% else %}
<span class="price-item price-item--regular" data-regular-price>
{{ 'products.product.sold_out' | t }}
</span>
{% endif %}
</dd>
</div>
<div class="price__sale">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.sale_price' | t }}</span>
</dt>
<dd>
<span class="price-item price-item--sale" data-sale-price>
{{ money_price }}
</span>
<span class="price-item__label" aria-hidden="true">{{ 'products.product.on_sale' | t }}</span>
</dd>
</div>
<div class="price__unit">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.unit_price_label' | t }}</span>
</dt>
</div>
</dl>
首次亮相主题片段->
产品卡网格.liquid
替换:
{%包括“产品价格”,变量:product.selected\u或\u first\u available\u variant%}
与:
{%包括“产品价格”,变量:product%}
然后在代码段->产品价格.liquid
替换:
{%-assign price=variant.price-%}
与:
{%-assign price=variant.price\u max-%}
我测试了它的首次亮相主题,它的工作。您也可以试试这个。在您的主题中,产品缩略图的代码是什么样子的?可能有某个地方引用了
product.price
或product.price\u min
,您可以将其更改为product.price\u max
@DaveB以下是整个产品-price.liquid代码,我读到的所有信息都表明,这个代码片段控制着整个网站的产品价格,但除了个别产品页面之外,我似乎无法让它在任何地方发生变化@DaveB这里是featured-product.liquid code-Hmm。奇怪的是,第一个代码片段似乎只引用了variant.price
,而不是product
对象上的任何价格字段。是的,这就是我更改为{%-assign price=product.price_max-%}
{%- assign money_price = price | money -%}
<dl class="price{% if available and compare_at_price > price %} price--on-sale{% endif %}" data-price>
{% if section.settings.show_vendor %}
<div class="price__vendor">
<dt>
<span class="visually-hidden">{{ 'products.product.vendor' | t }}</span>
</dt>
<dd>
{{ product.vendor }}
</dd>
</div>
{% endif %}
<div class="price__regular">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.regular_price' | t }}</span>
</dt>
<dd>
{% if available %}
{% if compare_at_price > price %}
<s class="price-item price-item--regular" data-regular-price>
{{ compare_at_price | money }}
</s>
{% else %}
<span class="price-item price-item--regular" data-regular-price>
{{ money_price }}
</span>
{% endif %}
{% else %}
<span class="price-item price-item--regular" data-regular-price>
{{ 'products.product.sold_out' | t }}
</span>
{% endif %}
</dd>
</div>
<div class="price__sale">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.sale_price' | t }}</span>
</dt>
<dd>
<span class="price-item price-item--sale" data-sale-price>
{{ money_price }}
</span>
<span class="price-item__label" aria-hidden="true">{{ 'products.product.on_sale' | t }}</span>
</dd>
</div>
<div class="price__unit">
<dt>
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.unit_price_label' | t }}</span>
</dt>
</div>
</dl>
{% include 'product-price-revised', price: product.price_max, compare_at_price: product.compare_at_price_max, available: product.available %}