0
votes

For some reason, when I wrap this metafield within an if statement it seems to break, but works perfectly when out of the statement. The product I'm looking at has a rating set within metafields of '3' but still shows 'Not Been Rated Yet' which is really odd!

      {% assign review = product.metafields.review %}
      {% assign key = 'rating' %}

      {% if product.metafields.rating != blank %}

        <img src="//cdn.shopify.com/s/files/1/1513/9752/t/3/assets/{{ review.rating }}.svg"/>
        <span>Scored {{ review.rating }}/5 with a <a href="#">Verified Tester</a></span>

      {% else %}

        <img src="//cdn.shopify.com/s/files/1/1513/9752/t/3/assets/unrated.svg"/>
        <span>Not been rated yet. <a href="#">Become a tester!</a></span>

      {% endif %}

Would anyone be able to help with this?

1

1 Answers

1
votes

This was fixed due to a name space error. As you're already within a 'product' you don't need to retell Shopify that you want to access the product... field.

Fixed by trying the if statement against 'review.rating != blank'