Displaying product ratings and review counts with metafields
Would you like to display a product’s average rating and total number of reviews in a particular spot on your store?
You can do this easily by adding review metafields to your theme code.
About review metafields:
Shopify provides two standard metafields: reviews.rating (stored as a rating type) and reviews.rating_count (stored as a number_integer type).These metafields offer:
– Average Rating: You can access this using {{ product.metafields.reviews.rating.value }}. For example, it might show “value”: “3.5”.
– Review Count: This is available through {{ product.metafields.reviews.rating_count }}. For example, it could display 125 reviews.
Additionally, you can retrieve the minimum and maximum rating values:
– Minimum Rating: Use {{ product.metafields.reviews.rating.value.scale_min }} to show the lowest rating value, like “1.0”.
– Maximum Rating: Utilize {{ product.metafields.reviews.rating.value.scale_max }} to indicate the highest rating value, such as “5.0”.
How to integrate review metafields into your theme code:
1. Go to your Shopify Admin >> Online Store >> Themes.
2. Under your published/live theme, click on the Actions button and choose Edit Code.
3. Find the “product.liquid” file within the theme code.
4. Insert the required code to showcase your desired metafields.
5. Save your modifications and preview any product in your store to view the changes.
Examples of reviews Metafields on your online store:
Please be aware that reviews metafields will provide numerical values exclusively.
You can customize the presentation by adding descriptive text to give context to this data.
For example:
Here’s how the metafields are displayed on your live store
With this approach, you can present important product ratings and review details to your customers in a clear and informative way.