SPR Shopify Rating App liquid for

Highlighted
Shopify Partner
35 0 3

I want to include properly formatted product ratings summaries for Google to include in their SERPs.

How do I call the following from SPR?

ratingValue

ratingCount

Here's what I have in my header section of product.liquid:

<section class="single-product" itemscope itemtype="http://schema.org/Product">
  <meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
  <meta itemprop="image" content="{{ product.featured_image.src | img_url: 'grande' }}">
<div style="position:absolute;left:-9999px;" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
  <span itemprop="itemReviewed">{{ product.title | escape }}</span>
    has a rating of <span itemprop="ratingValue">{{ product.metafields.spr.rating }}</span> stars
  based on <span itemprop="ratingCount">{{ product.metafields.spr.review_count }}</span> reviews. 
</div>

 

but product.metafields.spr.rating and product.metafields.spr.review_count are returning null when I have 5 reviews and 5/5 stars overall.

What are the correct functions and/or variables for this?

Digital marketing and marketing tech expert. I help businesses build wholistic customer flows from advertising, landing pages, ecommerce, lead capture to crm, email marketing, retargeting and more.
0 Likes
Highlighted
Shopify Expert
9925 103 1763

Doesn't the spr.reviews metafield already contain the HTML needed here? That metafield would contain things like:

<div class="spr-summary" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">
<meta itemprop="itemreviewed" content="foo" />
<meta itemprop="votes" content="15" />
<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating" class="spr-starrating spr-summary-starrating">
<meta itemprop="average" content="5.0" />
<meta itemprop="best" content="5" />
<meta itemprop="worst" content="1" />
...

If you need to change that default html that the app adds to the metafield I suppose you could use some string parsing to pull the values out and show them in different ways.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
35 0 3

I guess so. I had some other code from another reviews app and it was throwing errors on Google's testing tool. 

https://search.google.com/structured-data/testing-tool/u/0/#url=https%3A%2F%2Fsnappytowels.com%2Fpro...

Thanks

Digital marketing and marketing tech expert. I help businesses build wholistic customer flows from advertising, landing pages, ecommerce, lead capture to crm, email marketing, retargeting and more.
0 Likes
Highlighted
New Member
1 0 0

The only property available in {{ product.metafields.spr }} is {{ product.metafields.spr.reviews }}.

{
    product: {
        ...,
        metafields: {
            ...,
            spr: {
                reviews: "<some html output for list of reviews>"
            },
            ...
        },
        ...
    }
}

You'll need to create a complex filter to get those values separated for the theme. You can also try using this chrome extension: https://shopifyfd.com/

0 Likes