Ad

Using Metafields And IF Statements

- 1 answer

I have been using metafields to try and add a list of downloads to my products. I have a few manuals that i want each product to have.

I am using this code:

                {% if product.metafields.document.doc_1 =='' %}
                   <p>There are no downloads for this product</p>
                     {% else %}
                    <h4 class="page-subheading productscategory_title">
                        Downloads
                    </h4>
                    <ul>
                      {% for field in product.metafields.document%}
                      <li>{{ field | last }}</li>
                      {% endfor %}
                    </ul>
                  </div>
                  {% endif %} 

but it doesn't seem to work.

Also is this the only way i can add links to files in a product without doing it in the description?

Ad

Answer

Use Boolean logic where ever you can for Shopify liquid. More details and use cases on the Boolean logic - https://help.shopify.com/themes/liquid/basics/true-and-false

Ad
source: stackoverflow.com
Ad