How can I access star rating badges in metafields?

Hey y’all,

does anyone know if there is a way to grab the star rating badges in metafields? I want to show the review rating on the collection page, but I don’t see much in the resources for this. I can still use liquid for it, but just curious if there is an actual metafield for it that we can pull.

Thanks,

The literal icon or just the total rating?

1 Like

Hi @JosiahHubbard ,

There’s a dedicated rating metafield type:

By default, Liquid would return a numeric value of the rating stored in a metafield. Here’s the example of a rating metafield:

A simple Liquid snippet to display the value:

The final output:

However, you can extract additional attributes from the payload and add some HTML and CSS to convert the numeric value into the “stars”. I tried it on my dev store and here’s the result:

And here’s the code. … or rather “the code”:

{% assign reviews = product.metafields.demo_set.rating.value %}

{% if reviews %}
 
 
 {% assign rating = reviews.rating | round %}
 {% assign max = reviews.scale_max | round %}
 {% for iteration in (1..max) %}
  {% if iteration <= rating %}
   
  {% else %}
   
  {% endif %}
 {% endfor %}
{% endif %}
2 Likes

How could I change the icon to another emoji for example? I would like to display the heat level of hot sauce and would like to showcase a fire emoji (and then have 3 in color for example and 2 grey) is that possible?

1 Like

I’m looking to do the same. Does anyone know how to do this?

As of this year (2024), Shopify has deprecated their Product Reviews app.