Card Rating
Stars on product cards in collections, search, recommendations and the cart drawer.
The card rating puts stars on every product in your collection grids, search results, recommendations and cart drawer, so shoppers compare products at a glance.
How you add it depends on your theme:
- Themes whose product cards take app blocks, like Horizon: add the 5zero Card Rating block to the product card in the Theme Editor.
- Other themes: add a small snippet to the theme's product card. It works everywhere the card appears, also in content the theme loads later, like predictive search.
Both get their star styles from the 5zero Core app embed.
Where to place it
- Collection pages
- Featured collection sections
- Search page
- Predictive search
- Product recommendations
- Cart page
- Cart drawer
Adding the block
- In the Theme Editor, open a collection template and select the product card.
- Click Add block and choose 5zero Card Rating from the Apps tab. Your theme offers it only if its cards take app blocks.
- Drag it where the rating should appear, for example below the title.
| Setting | What it does |
|---|---|
| Show from (reviews), Show up to (reviews) | Products outside this range hide the rating. |
| Structure | The text of the rating. Default: {stars} {rating} ({count}). Placeholders: {stars}, {star}, {rating}, {rating_decimal}, {max}, {count}, {count_compact}. See text templates for how they work. |
| 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. |
| Custom CSS | Applies to this block only. See Customising blocks. |
Snippet to add in product cards
Open your theme code and find the snippet that renders a product card. In most themes it is snippets/card-product.liquid or snippets/product-card.liquid. Inside it, the product is usually called card_product. Add this where the rating should appear, for example below the title:
Merino Sneaker
€129.00
4.8 (126){%- assign fiveoh = card_product.metafields['app--324569563137'] -%}
{%- if fiveoh.rating_count.value > 0 -%}
<span class="fo-stars" style="--fo-rating: {{ fiveoh.rating.value.rating }}"></span>
{{ fiveoh.rating.value.rating }} ({{ fiveoh.rating_count.value }})
{%- endif -%}The texts are in English to keep the code short. Other languages
This shows five stars filled to the rating, then the rating and the review count, and nothing on products without reviews. The image, title and price in the preview are your theme's card; the snippet adds the line below them. It needs no CSS of its own: the stars are styled by the 5zero Core app embed.
If your theme uses another variable for the product in its card, replace card_product with it. If the theme has more than one card snippet, for example a separate one for search results, add the snippet to each.
Star styles
The stars' color, size and icons are set once in the 5zero Core app embed. Without it, the fo-stars span has no styles and shows nothing.
Data
The snippet reads these metafields of the card's product. Their full structure is in the reference.
rating: the average rating, including the reviews of the product's variants. Read it with.value.rating.rating_count: the number of reviews behind it.rating_count_compact: the same number, shortened for tight spaces, like12.9k.
Examples
The snippet is your theme's code, so you can shape it freely. Each example replaces the snippet above. 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.
Out of 5, with a minimum
Shows 4.8/5 · 126 reviews, and only for products with at least five reviews, so a single early review does not decide the first impression:
Merino Sneaker
€129.00
{%- assign fiveoh = card_product.metafields['app--324569563137'] -%}
{%- if fiveoh.rating_count.value >= 5 -%}
<p class="reviews-card-rating">
<span class="fo-stars" style="--fo-rating: {{ fiveoh.rating.value.rating }}"></span>
<span><strong>{{ fiveoh.rating.value.rating }}</strong>/5 · {{ fiveoh.rating_count.value }} reviews</span>
</p>
{%- endif -%}The texts are in English to keep the code short. Other languages
Accessible stars
Screen readers do not see the stars, as they are drawn with CSS. A role and a label make them readable. This changes nothing visible, so it needs no CSS:
{%- assign fiveoh = card_product.metafields['app--324569563137'] -%}
{%- if fiveoh.rating_count.value > 0 -%}
{%- assign rating = fiveoh.rating.value.rating -%}
<span class="fo-stars" style="--fo-rating: {{ rating }}" role="img" aria-label="{{ rating }} out of 5 stars"></span>
{{ rating }} ({{ fiveoh.rating_count.value }})
{%- endif -%}The texts are in English to keep the code short. Other languages
Troubleshooting
- No stars on cards: check that the 5zero Core app embed is on. With the snippet, check that it is inside the card's loop and uses the card's product variable.
- Stars on the product page but not in search: the theme renders search results with another snippet. Add the snippet there too.
- The stars sit too high or too low: set
vertical-alignordisplay: flex; align-items: centeron the wrapper in 5zero Core's Custom CSS.