Skip to content

Shopify » Rating

A Shopify Rating type allows you to store a number on a scale that you define, for example a score from 1 to 5.

When you create or edit a Rating field, you must enter both a Scale minimum and a Scale maximum, where the minimum must be lower than the maximum. In the editor, decimals are allowed (for example 4.5), but the value must stay within the scale.

The entered rating is then available as a Rating object with rating, scale_min and scale_max properties, for example:

{% assign score = product.metafields.accentuate.quality_score.value %}
<p>Rated {{ score.rating }} out of {{ score.scale_max }}</p>

Since rating is a number, you can compare it directly:

{% assign score = product.metafields.accentuate.quality_score.value %}
{% if score.rating >= 4 %}
<span class="badge">Top rated</span>
{% endif %}

A Shopify » Rating (List) field holds several ratings that share the same scale. Loop over the list to output each one:

{% for score in product.metafields.accentuate.scores.value %}
<p>{{ score.rating }} / {{ score.scale_max }}</p>
{% endfor %}