2017-10-27 4 views
0

Wie Sie sehen können, in der letzten Zeile des Codes berechne ich den Grundpreis pro Meter dieses Produkts. Leider wird dieser Preis nur einmal für alle Varianten berechnet. Ausgabe des speziellen Grundpreises für jede Produktvariante. Kannst du mir helfen wie das geht?Sicher eine Variable @ shopify Thema

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

Antwort

0

Wenn Sie Grundpreis für jede Variante zeigen wollen, dann können Sie es in der Schleife wie das tun:

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