Skip to main content
All CollectionsContentCart layout
Add star ratings for products in cart layouts and SmartBlocks
Add star ratings for products in cart layouts and SmartBlocks

Show your customers the ratings for your products.

Updated over 7 months ago

You can show the star rating of a product in your abandonment emails or recommendations. This can either be as a number or a capture of any image.


Before you start

Things you need to know:


Jinja code

If we can only capture the numeric value, it's still possible to create a star rating by using the Jinja code outlined below:

{# this assumes the rating is stored in product.ex.rating but you may need to check that is the case #}

{% for x in range(product.ex.rating|round|int) %}  
<img src="http://path/to/your.image/1star.jpg">
{% endfor %}
{% for x in range((5) - (product.ex.rating|round|int)) %}  
<img src="http://path/to/your.image/emptystar.jpg">
{% endfor %}
  • The first For statement loops over the value and adds the amount of stars based on the rating, for example, product rating 3.5/5 = add 3 stars.

  • The second For statement loops over the value and adds the remaining amount, for example, product rating 3.5/5 = add 2 empty stars.

  • You can add any styling you require to the images or around the block.

  • This code rounds the value to the nearest integer; 3.5 rounds to 3.

  • This code assumes you have two images; one for a full star and one for an empty star.

Did this answer your question?