Rating Bar
A full-width strip with stars, rating, review count and an optional logo.
The 5zero Rating Bar is a horizontal strip with stars, the rating and the review count, like ★★★★★ 4.8 based on 2,341 reviews, and an optional logo.
Where to place it
- Homepage
- Landing pages
- Header
- Footer
Adding it to your theme
- In the Theme Editor, open the template, for example the homepage.
- Click Add block in a section and choose 5zero Rating Bar from the Apps tab.
- Pick the Review scope: All reviews, All product reviews, Store reviews for reviews about your shop, or This product on product pages.
Settings
| Setting | What it does |
|---|---|
| Review scope | This product, All product reviews, Store reviews (about the shop itself) or All reviews. This product shows all reviews outside product pages. |
| Show from (reviews), Show up to (reviews) | Hide the bar outside this range. On product pages this counts the product's reviews, elsewhere the reviews in this block. |
| Structure | The text of the bar. Default: {logo} {stars} <b>{rating}</b> based on <b>{count}</b> {review|reviews}. Placeholders: {logo}, {stars}, {star}, {rating}, {rating_decimal}, {max}, {count}, {count_compact}. See text templates for how they work. |
| Link, Open link in new tab | Where a click goes, for example #product-reviews. Empty shows no link. |
| Layout | Inline sits in the text flow. Centered strip and Full-width strip get a background, centered in the section or across the full screen width. |
| Background color | Empty is transparent. |
| 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. |
| Logo, Logo max width | The image for {logo}, like a review platform logo. |
| 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. Which ones depends on the Review scope: product reads the product's rating, mixed the shop's rating, and store the shop's store_reviews_rating.
ratingandrating_count: on a product the product's own, on the shop those of all reviews.rating_count_compact: the count shortened for tight spaces, like2.3k.store_reviews_ratingand its count, on the shop: store reviews only, about the shop rather than a product.product_reviews_ratingand its count, on the shop: product reviews only.
Examples
The block reads rating and rating_count from the product or the shop, depending on the scope; store scope reads store_reviews_rating. To restyle the block itself, its colors are also CSS custom properties: --fo-rating-bar-bg and --fo-rating-bar-color in its Custom CSS override the color settings.
The examples below build the rating into your own theme code. 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 in the announcement bar
The shop's own metafields hold the rating across all reviews. rating_count_compact gives a short number for tight spaces, like 2.3k:
{%- assign fiveoh = shop.metafields['app--324569563137'] -%}
{%- if fiveoh.rating_count.value > 0 -%}
<a href="/pages/reviews" class="reviews-announcement">
<span class="fo-stars" style="--fo-rating: {{ fiveoh.rating.value.rating }}"></span>
Rated {{ fiveoh.rating.value.rating }} from {{ fiveoh.rating_count_compact.value }}+ reviews
</a>
{%- endif -%}The texts are in English to keep the code short. Other languages
Product reviews only
The shop's rating counts every review. To count only product reviews, read product_reviews_rating and product_reviews_rating_count; for reviews about your shop, store_reviews_rating and store_reviews_rating_count:
{%- assign fiveoh = shop.metafields['app--324569563137'] -%}
<p class="reviews-rating-line">
<span class="fo-stars" style="--fo-rating: {{ fiveoh.product_reviews_rating.value.rating }}"></span>
<span>
<strong>{{ fiveoh.product_reviews_rating.value.rating }}</strong> based on
<strong>{{ fiveoh.product_reviews_rating_count.value }}</strong> product reviews
</span>
</p>The texts are in English to keep the code short. Other languages
Troubleshooting
- No rating shows: check that there are reviews for the chosen Review scope. Store reviews only counts reviews about your shop.
- The background does not reach the edges: set Layout to Full-width strip.