Skip to main content

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

  1. Product page, around the product title

Adding it to your theme

  1. In the Theme Editor, open a product template.
  2. In the section with the product title, click Add block and choose 5zero Product Rating from the Apps tab.
  3. Drag it below the title.
  4. To link it to your reviews, set Link to #product-reviews, the Anchor ID of the Review List.

Settings

SettingWhat 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.
StructureThe 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.
LinkWhere a click goes, for example #product-reviews to scroll to the review list. Empty shows no link.
Text color, Text sizeEmpty text color uses your theme's. Text size is relative to your theme's, 100% keeps it.
Star color, Star sizeEmpty star color uses the one from 5zero Core. Star size is relative to Core's, where the star icons are set too.
AlignmentLeft, center or right in its row.
Anchor IDAn ID links can jump to.
Custom CSSApplies 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.

  1. rating on the product: the average rating, including the reviews of its variants.
  2. rating_count on 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:

4.8/5 (126 reviews)
{%- 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:

4.8

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

  1. No rating shows: check that the product has reviews, or set Show from (reviews) to 0.
  2. The click does not scroll: the Link must match the Anchor ID of the review list, with a # in front.