2017-10-19 91 views
0

在page.template中,我試圖爲購物車中的每個產品顯示一個單獨的行,這意味着如果存在相同的產品,則在例如,3次,我需要在3個單獨的行中顯示它。如何顯示每一行line_item.quantity(Liquid)

的基本結構是這樣的:

{% for item in cart.items %} 
       {% for quantity in item.quantity %} 
       <p>show something</p> 
       {% endfor %} 
    {% endfor %} 

但是<p>沒有顯示。

+0

看來,如果你有一個數組爲「中」的那液體的「對」只是工作參數,因爲item.quantity不是一個數組而是一個整數值,所以for不起作用。仍在尋找解決方案 –

回答

0

這sintax工作:

{% for item in cart.items %} 
      {% for i in (1..item.quantity) %} 
      <p>show something</p> 
      {% endfor %} 
{% endfor %} 

(!扣...自動擊掌)