Search code examples
shopifyshopify-app

Shopify Product Review app get total review number


I want to display how many people leave feedback and the rating number for a product on every product row on the collection page, home page or any within product loop with the shopify Product Review App.

But I can't find any way to do it.

Can anyone please give me any suggestion, how can I do this?


Solution

  • Finally, I'm able to display how many people rating for a product. Here is the code

    {% if product.metafields.spr.reviews %}
    
          {% capture review_data %}{{ product.metafields.spr.reviews }}{% endcapture %}
    
          {% if review_data contains '"votes"' %}
              {% assign keyword = '"votes"' %}
          {% else  %}
              {% assign keyword = '"reviewCount"' %}
          {% endif %}
    
          {% assign rd_a1 = review_data | split: keyword %} 
      {% assign rd_a2 = rd_a1[1] | split: "=" %}
          {% assign rd_a3 = rd_a2[1] | split: '"' %}
          {% assign product__reviews-count = rd_a3[1] | plus: 1 | minus: 1 %}
    
    {% endif %}
    {{ product__reviews-count }}