如何在shopify中为可变产品添加价格标签

时间:2019-08-08 21:58:21

标签: html shopify shopify-template

我在shopify问题上添加了带有$金额的标签(正常价格和销售价格),当我从产品选项金额更改变量时,我面临的问题是自动更改,但是我添加的标签突然消失了。两张照片都附上了。

https://drive.google.com/file/d/1KdnfVJrvspl59i9yFLJZ62yvU_W7av6T/view?usp=sharing

withlabel:

https://drive.google.com/file/d/15A9-Tx2AZuPR5ewfDhLUo65a7TYUCJ8K/view?usp=sharing

我已经为简单的产品添加了代码,即使对于可变的产品代码也位于此处:

{%- comment -%} PRICE {%- endcomment -%}
<div class="countdown-wrapper">
  {%- include 'limited-offer' -%}
</div>
{%- if settings.price_range and product.price_varies -%}
<div class="price-range price">
  <span class="price-new"><span class="money">{{- product.price_min | money -}}</span></span> - <span class="price-new"><span class="money">{{- product.price_max | money -}}</span></span>
</div>
{%- endif -%}
<div class="product-single__price-{{- section.id -}}">
  <div id="price" class="price">
    {%- if current_variant.compare_at_price > current_variant.price -%}
    <span  id="ProductPrice-{{- section.id -}}" class="amount price-new">
      <span class="money">
        <label>Sale price:</label>&nbsp;&nbsp;
        {{- current_variant.price | money -}}
      </span>
    </span>
    {%- else -%}
    <span id="ProductPrice-{{- section.id -}}" class="amount price-new">
      <span class="money ">
<label>Regular price:</label>&nbsp;&nbsp;
        {{- current_variant.price | money -}}</span>
    </span>
    {%- endif -%}
    <br>
    <span id="ComparePrice-{{- section.id -}}" class="amount price-old{%- unless current_variant.compare_at_price > current_variant.price %}{{- " hide" -}}{%- endunless -%}">
      <span class="money">
            <label>Regular price:</label>&nbsp;&nbsp;
        {%- if current_variant.compare_at_price > current_variant.price -%}
        {{- current_variant.compare_at_price | money -}}
        {%- endif -%}
      </span>
    </span>
    <span class="hide" itemprop="price">{{- product.price | money_without_currency -}}</span>
    <meta itemprop="priceCurrency" content="USD" />
  </div>
</div>

我添加的标签标签有效,但是当我更改产品选项时,我的两个标签常规价格和销售价格都消失了。我希望显示在我选择任何选项标签时应显示的数量,例如 常规价格:US $ 200 销售价格:$ 150

1 个答案:

答案 0 :(得分:0)

乌斯曼, 当您更改产品选项时,它将触发onchange事件,并且根据新产品选项的选择将覆盖产品信息。能否请您分享主题名称,以便我可以在js文件中更改标签的位置为您提供确切的帮助。

通常,theme.js中提到的代码,请参考以下屏幕截图包含事件,该事件在产品选项更改时触发: https://drive.google.com/file/d/1MEFCGV6DWk6JUzxrVgK6fczbFqUTMpH2/view?usp=drivesdk