简体   繁体   English

如何在shopify中的可变产品上添加带有价格的标签

[英]how to add label with price on variable product in shopify

i am adding a label (regular price and sale price) with $ amount on shopify problem which i am facing when i change the variable from product option amount automatically changed but label which i add with amount that suddenly gone.我在 shopify 问题上添加了一个带有 $ 金额的标签(正常价格和销售价格),当我更改产品选项金额中的变量时我面临的问题自动更改,但我添加的标签金额突然消失了。 both shots are attached.两张照片都附上了。

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

withlabel:带标签:

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

i already add for simple product even for variable product code is here:我已经添加了简单的产品,即使是可变产品代码也在这里:

{%- 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>

the label tag which i add that works but when i change the product option my both labels regular price and sale price gone.我添加的标签标签有效,但是当我更改产品选项时,我的两个标签的正常价格和销售价格都消失了。 i am expecting to show when i select any option label should show with amount like regular price: $200 sale price: $150我希望在我选择任何选项时显示标签应该显示的金额如正常价格:200 美元 销售价格:150 美元

Usman, when you change the product options it trigger onchange event and product information override according to new product option selection. Usman,当您更改产品选项时,它会根据新的产品选项选择触发 onchange 事件和产品信息覆盖。 Can you please share theme name so that i can exact help you from where you can change label in js file.您能否分享主题名称,以便我可以确切地帮助您从哪里可以更改 js 文件中的标签。

Usually, code mentioned in theme.js, please refer below screenshot include event that trigger on change of product option: https://drive.google.com/file/d/1MEFCGV6DWk6JUzxrVgK6fczbFqUTMpH2/view?usp=drivesdk通常,theme.js 中提到的代码,请参考下面的截图包括更改产品选项时触发的事件: https ://drive.google.com/file/d/1MEFCGV6DWk6JUzxrVgK6fczbFqUTMpH2/view?usp=drivesdk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM