Product Rating
Stars, rating and review count for the current product, next to the title.
The 5zero Product Rating block shows the current product's stars, rating and review count, like ★★★★★ 4.8/5 (126 reviews). Linked to your review list, a click takes them straight to the reviews.
The rating includes the reviews of all the product's variants.
Where to place it
- Product page, around the product title
Adding it to your theme
- In the Theme Editor, open a product template.
- In the section with the product title, click Add block and choose 5zero Product Rating from the Apps tab.
- Drag it below the title.
- To link it to your reviews, set Link to
#product-reviews, the Anchor ID of the Review List.
Settings
| Setting | What it does |
|---|---|
| Show from (reviews), Show up to (reviews) | Products outside this range hide the rating. Use Show up to to add a second rating block for products with few reviews. |
| Structure | The text of the rating. Default: {stars} {rating}/{max} (<u>read {count} {review|reviews}</u>). Placeholders: {stars}, {star}, {rating}, {rating_decimal}, {max}, {count}, {count_compact}. See text templates for how they work. |
| Link | Where a click goes, for example #product-reviews to scroll to the review list. Empty shows no link. |
| Text color, Text size | Empty text color uses your theme's. Text size is relative to your theme's, 100% keeps it. |
| Star color, Star size | Empty star color uses the one from 5zero Core. Star size is relative to Core's, where the star icons are set too. |
| Alignment | Left, center or right in its row. |
| Anchor ID | An ID links can jump to. |
| Custom CSS | Applies to this block only. See Customising blocks. |
Data
The block reads these metafields. Your theme code can read the same ones; their full structure is in the reference.
ratingon the product: the average rating, including the reviews of its variants.rating_counton the product: the number of reviews behind it.
rating is not a plain number: read it with .value.rating, like product.metafields['app--324569563137'].rating.value.rating.
Examples
To restyle the block itself, see Customising blocks. These examples put the rating into your own product template instead. Each example brings the CSS for exactly the look of its preview, scoped to its own classes so it does not touch the rest of your theme. Only the font and the text color come from your theme. The stars (fo-stars) need 5zero's star styles on the page, which every 5zero block and the Card Rating app embed load.
Rating next to the title
Stars, rating and count, linked to the review list:
{%- assign fiveoh = product.metafields['app--324569563137'] -%}
{%- if fiveoh.rating_count.value > 0 -%}
<a href="#product-reviews" class="reviews-rating">
<span class="fo-stars" style="--fo-rating: {{ fiveoh.rating.value.rating }}"></span>
{{ fiveoh.rating.value.rating }}/5 ({{ fiveoh.rating_count.value }} reviews)
</a>
{%- endif -%}The texts are in English to keep the code short. Other languages
Big number
The rating as a large number, for a review summary above the list:
Based on 126 reviews
{%- assign fiveoh = product.metafields['app--324569563137'] -%}
<div class="reviews-score">
<strong class="reviews-score__value">{{ fiveoh.rating.value.rating }}</strong>
<div>
<span class="fo-stars" style="--fo-rating: {{ fiveoh.rating.value.rating }}"></span>
<p>Based on {{ fiveoh.rating_count.value }} reviews</p>
</div>
</div>The texts are in English to keep the code short. Other languages
Troubleshooting
- No rating shows: check that the product has reviews, or set Show from (reviews) to
0. - The click does not scroll: the Link must match the Anchor ID of the review list, with a
#in front.