我試圖做類似這樣的問題的東西:Shopify購物車 - 顯示項基於標題
Shopify - If item in cart belongs to a specific collection
,我已經試過編輯代碼,以滿足我的需求,但它似乎增加一倍輸出。
我要的是檢查,看是否有購物車中的商品屬於特定集合(或檢查標題),然後下方顯示相關項目。
我當前的代碼是:
{% for item in cart.items %}
{% for collection in item.product.collections %}
{% if collection.handle == "mukluks" %}
this is a mukluk
{% endif %}
{% endfor %}
{% endfor %}
但是輸出「這是一個mukluk」每有一個比賽的時間。我仍然試圖找出如何將它限制爲一個。也許用forloop?
這對我來說似乎更有效率,所以我將它標記爲正確答案而不是我的。 – Patrick 2014-12-05 18:23:45