Javascript Shopify选项选择器不改变价格

Javascript Shopify选项选择器不改变价格,javascript,shopify,liquid,timber,Javascript,Shopify,Liquid,Timber,我正在尝试修复我的选项选择,因为之前这家公司安装了Bold,它干扰了我们的选项选择。我有选择显示,但确切地说,我想要它,但它现在的工作。。。但无论我做什么,价格都不会改变!有人能帮我找出我在这里遗漏了什么吗 第一个代码段包含在我的“product form.liquid”代码段中 <form action="/cart/add" method="post" enctype="multipart/form-data" id="AddToCartForm" class="form-ve

我正在尝试修复我的选项选择,因为之前这家公司安装了Bold,它干扰了我们的选项选择。我有选择显示,但确切地说,我想要它,但它现在的工作。。。但无论我做什么,价格都不会改变!有人能帮我找出我在这里遗漏了什么吗

第一个代码段包含在我的“product form.liquid”代码段中

    <form action="/cart/add" method="post" enctype="multipart/form-data" id="AddToCartForm" class="form-vertical">

    <select name="id" id="ProductSelect" class="product-single__variants">
                {% for variant in product.variants %}
                  {% if variant.available %}

                    <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

                  {% else %}
                    <option disabled="disabled">
                      {{ variant.title }} - {{ 'products.product.sold_out' | t }}
                    </option>
                  {% endif %}
                {% endfor %}
              </select>
      {% if settings.product_swatches %}
        {% if product.available and bold_variants_size > 1 %}
          {% for option in product.options %}
            {% include 'swatch' with option %}
          {% endfor %}
        {% endif %}
      {% endif %}
      {% if settings.product_different_swatches %}
        {% include 'different_product_swatches' with product.type, titlee: settings.product_different_swatches_title %}
      {% endif %}

     <div class="formWrap">
      <div class="price-variant-wrap">
        <span class="priceText">PRICE:</span>
         <span class="visually-hidden">{{ 'products.general.regular_price' | t }}</span>
              <span id="ProductPrice" class="h2" itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}">
                {{ current_variant.price | money }}
              </span>

              {% if product.compare_at_price_max > product.price %}
                <span class="visually-hidden">{{ 'products.general.sale_price' | t }}</span>
                <p id="ComparePrice">
                  {{ 'products.product.compare_at' | t }} {{ current_variant.compare_at_price | money }}
                </p>
              {% endif %}
      </div>

      {% assign isFreeGift=false %}
      {% for tag in product.tags %}
        {% if tag =='SECOMAPP_FREEGIFT'%}
          {% assign isFreeGift=true %}
        {% endif %}
      {% endfor %}
      {% if isFreeGift == false %}
      <div class="product-bottom-wrap">

        <div class="fancy_btn_wrap">
          <div class="product-single__add-to-cart">
          {% if settings.prod_quantity == 'plus-minus' %}
              {% include 'quantity' %}
          {% elsif settings.prod_quantity == 'number' %}
            <label for="Quantity" class="quantity-selector">{{ 'products.product.quantity' | t }}</label>
            <input type="number" id="Quantity" name="quantity" value="1" min="1" class="quantity-selector">
          {% endif %}
            <div class="submit-container">
              <button type="submit" name="add" id="AddToCart" data-price="{{ current_variant.price | money_without_currency }}" class="btn {{settings.product_page_button_type}} ">
                <input type="hidden" name="return_to" value="back" />
                <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
              </button>
            </div>
          </div>
        </div>
      </div>
       {% endif %}
    </div>
        <div id="shopmessage-checkbox" class="fbmessage"></div>
    </form>
    <div class="sca-fg-cat-list" style="display: none;" name="secomapp-fg-data-{{ product.id }}"> </div>

{product.variants%中的变量为%0}
{%if variant.available%}
{{variant.title}}-{{variant.price}货币}
{%else%}
{{variant.title}}-{{'products.product.salled|t}
{%endif%}
{%endfor%}
{%if settings.product_样例%}
{%如果product.available和粗体_变体_size>1%}
{product.options%中的选项为%s}
{%include'swatch'和选项%}
{%endfor%}
{%endif%}
{%endif%}
{%if settings.product\不同的\样例%}
{%使用product.type,titlee:settings.product\u different\u-swatches\u title%包含“different\u-product\u-swatches”
{%endif%}
价格:
{{产品.一般.正常价格{t}
{{current_variant.price{124; money}}
{%if product.compare_at_price_max>product.price%}
{{产品.一般.销售价格}

{{'products.product.compare|u at'| t}{{{{current_variant.compare|u at|u price | money}}

{%endif%} {%assign isFreeGift=false%} {product.tags%中的标记的%s} {%if标记=='SECOMAPP\u FREEGIFT%} {%assign isFreeGift=true%} {%endif%} {%endfor%} {%if isFreeGift==false%} {%if settings.prod_quantity=='加减'%} {%include'数量'%} {%elsif settings.prod_数量=='编号'%} {{'products.product.quantity'|t} {%endif%} {{'products.product.add_-to_-cart'|t} {%endif%}
下面的代码位于我的product.template中

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                <meta itemprop="priceCurrency" content="{{ shop.currency }}">

                <link itemprop="availability" href="http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}">
                {% if settings.product_description_location == 'above_form' %}
                <div class="product-description rte" itemprop="description">

                 {% if product.description contains '<!-- split -->' %} 
                   {{ description[0] }} 
                 {% else %} 
                   {{ product.description }} 
                 {% endif %}
                </div>
              {% endif %}
                {% comment %}
                  ID addToCartForm is a selector for the ajax cart plugin
                {% endcomment %}
                {% include 'product-form' %}
                {% include 'addthis' %}

              </div>

    <script>
    var selectCallback = function(variant, selector) {
      {% if settings.product_swatches %}
      // BEGIN SWATCHES
      if (variant) {
        var form = jQuery('#' + selector.domIdPrefix).closest('form');
        for (var i=0,length=variant.options.length; i<length; i++) {
          var radioButton = form.find('.swatch[data-option-index="' + i + '"] :radio[value="' + variant.options[i] +'"]');
          if (radioButton.size()) {
            radioButton.get(0).checked = true;
          }
        }
      }
      // END SWATCHES
      {% endif %}
      timber.productPage({
        money_format: "{{ shop.money_format }}",
        variant: variant,
        selector: selector
      });
    };

    jQuery(function($) {
      new Shopify.OptionSelectors('productSelect', {
        product: {{ product | 'json' }},
        onVariantSelected: selectCallback,
        enableHistoryState: false
      });

      // Add label if only one product option and it isn't 'Title'. Could be 'Size'.
      {% if product.options.size == 1 and product.options.first != 'Title' %}
        $('.selector-wrapper:eq(0)').prepend('<label for="productSelect-option-0">{{ product.options.first | escape }}</label>');
      {% endif %}

      // Hide selectors if we only have 1 variant and its title contains 'Default'.
      {% if bold_variants_size == 1 and bold_selected_or_first_available_variant.title contains 'Default' %}
        $('.selector-wrapper').hide();
      {% endif %}
    });

    {% unless product.title == 'Gift Card' %}
      var checkExist = setInterval(function() {
        if ($('.spr-badge .spr-badge-caption').length) {
          var rating = $('.spr-starrating.spr-summary-starrating').html();
          var noOfRatings = $('.spr-summary-caption').html();
          var ratingHolder = $('.ratingHolder');
          ratingHolder.prepend(noOfRatings);
          ratingHolder.prepend(rating);
          ratingHolder.click(function(){
            $('#product_tabs .tab_3 a').trigger('click');
            $('html, body').animate({
              scrollTop: $("#product_tabs").offset().top - $('.site-header').outerHeight() - 30
            }, 1000);
          });
          clearInterval(checkExist);
        }
      });
    {% endunless %}
    </script>

{%if settings.product\u description\u location=='在表单“%”上方
{%如果product.description包含“”%}
{{说明[0]}
{%else%}
{{product.description}}
{%endif%}
{%endif%}
{%comment%}
ID addToCartForm是ajax购物车插件的选择器
{%endcomment%}
{%include'产品形式“%”
{%include'添加此“%”
var selectCallback=函数(变量、选择器){
{%if settings.product_样例%}
//开始样例
if(变体){
var form=jQuery('#'+selector.domIdPrefix).closest('form');

对于(var i=0,length=variant.options.length;i如果您在使用粗体之前回到液体,您将处于一个良好的位置。您的代码应该可以正常工作。从那时起,您可以自定义以使其成为您今天想要的样子。Shopify对时光倒流有一个基本的支持。您尝试过吗?或者从您的主题供应商那里获得您的主题副本加粗前的r?这也会给你提供干净的工作液。

嘿,大卫,谢谢你的帮助!我花了一段时间才弄清楚,但实际上是因为一个隐藏元素,一个重复的产品表单(为添加到购物车粘性而制作)显示的是变体而不是非粘性表单。把所有这些都去掉,现在它工作得非常完美!