2017-10-27 14 views
0

コードの最後の行では、この製品の1メートルあたりの基本価格を計算しています。残念ながら、この価格はすべてのバリアントで1回計算されます。すべての製品バリアントの特別基本価格を出力する。これを行う方法を私に教えてもらえますか?安全な変数@ shopifyテーマ

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

答えて

0

あなたは、各バリアントのGrundpreisを表示したい場合は、そのようなループの中でそれを行うことができます。

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