Skip to main content

Add star ratings to cart layouts and SmartBlocks

Show your customers the ratings for your products.

Updated over 2 weeks ago

Show your customers the ratings for your products in cart layouts and SmartBlocks. You can display a product's star rating in your abandonment emails or recommendations, either as a numerical value or as an image.


Before you start

Things you need to know:


Jinja code

If you can only capture the numeric value, you can still create a star rating with the Jinja code.

See the below example to learn how to do it:

{# 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?