【问题标题】:Safe a variable @ shopify theme安全变量@shopify 主题
【发布时间】:2017-10-27 14:35:20
【问题描述】:

如您所见,在代码的最后一行中,我计算了该产品每米的基本价格。不幸的是,对于所有变体,这个价格只计算一次。为每个产品变体输出特殊的基本价格。你能帮我看看怎么做吗?

  <p class="product-single__price product-single__price-{{ section.id }}{% unless current_variant.available %} product-price--sold-out{% endunless %}">
        {% if current_variant.compare_at_price > current_variant.price %}
            <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
            <s id="ComparePrice-{{ section.id }}">{{ current_variant.compare_at_price | money }}</s>
            <span class="product-price__price product-price__price-{{ section.id }} product-price__sale product-price__sale--single">
              <span id="ProductPrice-{{ section.id }}"    
                itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}">
                {{ current_variant.price | money }}
              </span>
              <span class="product-price__sale-label product-price__sale-label-{{ section.id }}">{{ 'products.product.on_sale' | t }}</span>
            </span>                  
        {% else %}
          <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
          <s id="ComparePrice-{{ section.id }}" class="hide">{{ current_variant.compare_at_price | money }}</s>
          <span class="product-price__price product-price__price-{{ section.id }}">
            <span id="ProductPrice-{{ section.id }}"
              itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}">
              {{ current_variant.price | money }}
            </span>
            <span class="product-price__sale-label product-price__sale-label-{{ section.id }} hide">{{ 'products.product.on_sale' | t }}</span>
          </span>
        {% endif %}  
        <p class="hint">Grundpreis: {{ product.price | times:current_variant1.title | divided_by:1000 | money}}/Meter</p> 
      </p>

【问题讨论】:

    标签: themes shopify


    【解决方案1】:

    如果你想为每个变体显示Grundpreis,那么你可以在循环中这样做:

    {% for variant in product.variants %}
        <p class="hint">Grundpreis: {{ product.price | times:variant.title | divided_by:1000 | money}}/Meter</p> 
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-03
      • 2018-05-01
      • 1970-01-01
      相关资源
      最近更新 更多