Product Card — Rating
Product card with star rating and review count.
About this module
A Shopify product card featuring a star-rating row and review count to build trust in collection grids.
Source code
Installation
- 1
Open Shopify Admin
Go to Online Store → Themes.
- 2
Edit code
Click the ellipsis (⋯) next to your theme and choose Edit Code.
- 3
Create the section
In the Sections folder, click Add a new section, name it mh-product-card-rating, and replace the contents with the Liquid source below.
- 4
Save
Save the file. The section now appears in the Theme Customizer.
- 5
Add it to the page
Open the Theme Customizer, click Add section, search for it and add it where you like.
Usage
- 1
Paste the section
Create `mh-product-card-rating` under Sections and paste the source.
{{ 'styles.css' | asset_url | stylesheet_tag }} <div class="mh-rating-card"> <a href="{{ product.url }}" class="mh-rating-media"> {% if product.featured_image %} <img src="{{ product.featured_image | image_url: width: 700 }}" alt="{{ product.featured_image.alt | escape }}" width="700" height="700" loading="lazy" /> {% else %} {{ 'product-3' | placeholder_svg_tag: 'mh-rating-ph' }} {% endif %} </a> <div class="mh-rating-body"> <a href="{{ product.url }}" class="mh-rating-title">{{ product.title }}</a> <span class="mh-rating-price">{{ product.price | money }}</span> {% if section.settings.show_rating %} <div class="mh-rating-stars"> <span class="mh-rating-fill" style="width: {{ product.metafields.rating.value | default: 4.6 | times: 20 }}%"></span> </div> {% endif %} {% if section.settings.show_review_count %} <span class="mh-rating-count">({{ product.metafields.reviews.rating_count.value | default: 24 }} reviews)</span> {% endif %} </div> </div> {% schema %} { "name": "MH Product Card Rating", "tag": "div", "settings": [ { "type": "checkbox", "id": "show_rating", "label": "Show rating", "default": true }, { "type": "checkbox", "id": "show_review_count", "label": "Show review count", "default": true }, { "type": "range", "id": "rating_max", "label": "Max rating", "min": 5, "max": 10, "step": 1, "default": 5 } ], "presets": [{ "name": "MH Product Card Rating", "category": "ModuleHarbor" }] } {% endschema %} - 2
Configure in the customizer
Adjust the settings that ship with the section schema.