Either "offers", "review", or "aggregateRating" should be specified - Google Error

Highlighted
Shopify Partner
18 1 10

Please read here if anybody ever encounters this problem.

I created 2 solutions for this 1st is for YOPTO review app  and 2nd is Shopify Review App

Please follow the instructions below:

 

YOPTO

depending on how your theme is structured please open where they put the schema tag please check on the following lists:

  1. template/product.liquid
  2. section/product-template.liquid
  3. snippets/product-template-variables.liquid
  4. snippets/product-template.liquid

Add this to the top of the file.

 

 {%- assign YOPTO_Review_Data = product.metafields.yotpo.bottomline | strip_html | split: 'rating' -%}
  {%- assign YOPTO_Rating = YOPTO_Review_Data[0] | replace: 'star', '' | replace: ' ', '' -%}
  {%- assign YOPTO_Review_Count = YOPTO_Review_Data[1] | replace: 'Reviews', '' | replace: ' ', '' -%}


  {%- if YOPTO_Review_Count ==  'Writeareview' -%}
  {%- assign YOPTO_Review_Count = 0 -%}
  {%- endif -%}

 

 

and on the schema value put this code to aggregateRating

 

{%- unless YOPTO_Review_Count == 0 %}
          "aggregateRating": {
            "@type": "AggregateRating",
            "ratingValue": "{{ YOPTO_Rating }}",
            "reviewCount": "{{ YOPTO_Review_Count }}"
          },
 {%- endunless %}

 

 

---------

Shopify Review App

depending on how your theme is structured please open where they put the schema tag please check on the following lists:

  1. template/product.liquid
  2. section/product-template.liquid
  3. snippets/product-template-variables.liquid
  4. snippets/product-template.liquid

 

Note: first you need to find if SPR already added a code in your theme. if you saw it, please remove as the code doesn't work anymore. 

Add or replace it (if the code already exists) in the file.

 

 

{%- assign review_rating = false -%}
{% if product.metafields.spr.reviews %}
  {% capture review_data %}{{ product.metafields.spr.reviews }}{% endcapture %}

  {%- assign rating_keyword = '"ratingValue":' -%}
  {%- assign rd_a1 = review_data | split: rating_keyword -%}
  {%- assign rd_a2 = rd_a1[1] | split: "," -%}
  {%- assign rd_a3 = rd_a2[0] | replace: '"', "" -%}
  {%- assign review_rating = rd_a3 | plus: 1 | minus: 1 -%}


  {%- assign count_keyword = '"reviewCount":' -%}
  {%- assign rd_a1 = review_data | split: count_keyword -%}
  {%- assign rd_a2 = rd_a1[1] | split: "," -%}
  {%- assign rd_a3 = rd_a2[0] | replace: '"', "" -%}
  {%- assign review_count = rd_a3 | plus: 1 | minus: 1 -%}
{% endif %}

 

 

and in your schema add this

 

{%- if review_rating %}
  "aggregateRating": {
     "@type": "AggregateRating",
     "ratingValue": "{{ review_rating }}",
     "reviewCount": "{{ review_count }}"
  },
 {%- endif %}

 

 

 

Hope that helps someone! Let me know if you need any help with this.

Leysam | The Shopify Guy  
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - Hire me full time or per hour :)


Email me at edwardwindtalker@gmail.com or add me on Skype: samypogs
0 Likes
Highlighted
Tourist
7 0 2

Did you fix this in the end? I have the exact same errors on my page!

0 Likes
Highlighted
New Member
6 0 0

Like many other people that have posted on this topic our website is outputting JSON product data and the Shopify reviews are also outputting JSON data. I have complete control over the product data as that is in liquid code, but maybe someone from Shopify could answer why there are settings for me to adjust the colour of the stars or which fields are mandatory or the exact wording of the message the user is shown on completion but there is no setting to stop the review module outputting JSON data. Surely it is better to not write the JSON data to the document than expect owners of Shopify sites to implement a bodge where they wait for the review module to finish writing to the page before deleting the content that has just been added.

0 Likes
Highlighted
Tourist
8 0 3

This is what my product-template looks like.  What do I need to add or delete to add aggregate?

 

{% render 'product-template',
  product: product,
  description_style: section.settings.description_style,
  image_container_width: section.settings.image_size,
  section_id: product.id,
  social: section.settings.social_enable,
  thumbnail_position: section.settings.thumbnail_position,
  thumbnail_arrows: section.settings.thumbnail_arrows,
  video_looping: section.settings.enable_video_looping,
  video_style: section.settings.product_video_style
%}

{% if settings.enable_product_reviews and settings.reviews_layout == 'full' %}
  <hr id="Reviews-{{ product.id }}" class="hr--large">
  <div class="index-section index-section--small product-reviews product-reviews--full">
    <div class="page-width">
      <div id="shopify-product-reviews" data-id="{{product.id}}">{{ product.metafields.spr.reviews }}</div>
    </div>
  </div>

{% endif %}

{% schema %}
  {
    "name": "Product pages",
    "settings": [
      {
        "type": "select",
        "id": "description_style",
        "label": "Description position",
        "default": "default",
        "options": [
          {
            "value": "default",
            "label": "Next to media"
          },
          {
            "value": "full",
            "label": "Below media"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "social_enable",
        "label": "Enable social sharing",
        "default": true
      },
      {
        "type": "header",
        "content": "Media"
      },
      {
        "type": "paragraph",
        "content": "Learn more about [media types](https://help.shopify.com/en/manual/products/product-media)"
      },
      {
        "type": "select",
        "id": "image_size",
        "label": "Image size",
        "default": "medium",
        "options": [
          {
            "value": "small",
            "label": "Small"
          },
          {
            "value": "medium",
            "label": "Medium"
          },
          {
            "value": "large",
            "label": "Large"
          }
        ]
      },
      {
        "type": "select",
        "id": "thumbnail_position",
        "label": "Thumbnail position",
        "default": "beside",
        "options": [
          {
            "value": "beside",
            "label": "Next to media"
          },
          {
            "value": "below",
            "label": "Below media"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "thumbnail_arrows",
        "label": "Show thumbnail arrows"
      },
      {
        "type": "checkbox",
        "id": "enable_video_looping",
        "label": "Enable video looping",
        "default": true
      },
      {
        "type": "select",
        "id": "product_video_style",
        "label": "Video style",
        "default": "muted",
        "options": [
          {
            "value": "muted",
            "label": "Video without sound"
          },
          {
            "value": "unmuted",
            "label": "Video with sound"
          }
        ],
        "info": "Video with sound will not autoplay"
      }
    ]
  }
{% endschema %}

 

0 Likes
Highlighted
Shopify Partner
18 1 10

@AOI_HS in your template find: snippets/product-template-variables.liquid

and then follow my instructions for Shopify Review App above 

 

Let me know if you need more help!

 

Cheers

Leysam | The Shopify Guy  
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - Hire me full time or per hour :)


Email me at edwardwindtalker@gmail.com or add me on Skype: samypogs
0 Likes
Highlighted
Tourist
8 0 3

Looks like that code already exists in my file.  I am trying to resolve following two errors in Google Console.  2020-10-12 14_00_45-Review snippets.png

 

 

 

{%- assign days_price_valid_until = 10 | times: 86400 -%}
{%- assign gtin_option = 'gtin' -%}
{%- assign is_barcode_available = false -%}
{%- if current_variant.barcode != blank -%}
  {%- assign is_barcode_available = true -%}
  {%- assign gtin_string_length = current_variant.barcode | size -%}
  {%- if gtin_string_length == 8 or gtin_string_length == 12 or gtin_string_length == 13 or gtin_string_length == 14 -%}
    {%- assign is_valid_gtin_length = true -%}
    {%- assign gtin_option = gtin_option | append: gtin_string_length -%}
  {%- endif -%}
{%- endif -%}
{%- assign review_rating = false -%}
{% if settings.enable_product_reviews %}
  {% if product.metafields.spr.reviews %}
    {% capture review_data %}{{ product.metafields.spr.reviews }}{% endcapture %}
    {%- assign rating_keyword = '"ratingValue"' -%}
    {%- assign rd_a1 = review_data | split: rating_keyword -%}
    {%- assign rd_a2 = rd_a1[1] | split: "=" -%}
    {%- assign rd_a3 = rd_a2[1] | split: '"' -%}
    {%- assign review_rating = rd_a3[1] | plus: 1 | minus: 1 -%}

    {%- assign count_keyword = '"reviewCount"' -%}
    {%- assign rd_a1 = review_data | split: count_keyword -%}
    {%- assign rd_a2 = rd_a1[1] | split: "=" -%}
    {%- assign rd_a3 = rd_a2[1] | split: '"' -%}
    {%- assign review_count = rd_a3[1] | plus: 1 | minus: 1 -%}
  {% endif %}
{% endif %}

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Product",
    "offers": {
      "@type": "Offer",
      "availability":"https://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
      "price": "{{ current_variant.price | divided_by: 100.00 }}",
      "priceCurrency": "{{ cart.currency.iso_code }}",
      "priceValidUntil": "{{ 'now' | date: '%s' | plus: days_price_valid_until | date: '%Y-%m-%d'}}",
      "url": "{{ shop.url }}{{ product.url }}"
    },
    "brand": {{ product.vendor | json }},
    "sku": {{ current_variant.sku | json }},
    "name": {{ product.title | json }},
    "description": {{ product.description | strip_html | json }},
    "category": "",
    "url": "{{ shop.url }}{{ product.url }}",
    {%- if is_barcode_available and is_valid_gtin_length %}
      "{{gtin_option}}": {{ current_variant.barcode | json }},
      "productId": {{ current_variant.barcode | json }},
    {%- elsif is_barcode_available %}
      "mpn": {{ current_variant.barcode | json }},
      "productId": {{ current_variant.barcode | json }},
    {%- endif -%}
    {%- if review_rating %}
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "{{ review_rating }}",
        "reviewCount": "{{ review_count }}"
      },
    {%- endif %}
    "image": {
      "@type": "ImageObject",
      "url": "https:{{ product.featured_media.preview_image | img_url: '1024x1024' }}",
      "image": "https:{{ product.featured_media.preview_image | img_url: '1024x1024' }}",
      "name": {{ product.title | json }},
      "width": 1024,
      "height": 1024
    }
  }
</script>

 

0 Likes
Highlighted
Tourist
8 0 3

..deleting what I wrote---

0 Likes
Highlighted
New Member
6 0 0

If you change:

    {%- if review_rating %}
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "{{ review_rating }}",
        "reviewCount": "{{ review_count }}"
      },

To:

    {%- if review_count > 0 -%}
      "aggregateRating": {
        "@type": "AggregateRating",
        "itemReviewed": {{ product.title | json }},
        "bestRating": "5",
        "worstRating": "1",
        "ratingValue": "{{ review_rating }}",
        "reviewCount": "{{ review_count }}"
      },

 That should sort it both issues. I believe the line itemReviewed is optional.

0 Likes
Highlighted
New Member
2 0 0

Hi,

I am getting warning messages "Missing Field Aggregate Ratings" and Missing Field Reviews" and "No Global Identifier" on couple of Product pages.

https://oskiandlottie.com.au/products/linen-face-mask-maple

https://oskiandlottie.com.au/collections/bedding/products/floor-cushion-tropical-jungle-khaki

https://oskiandlottie.com.au/products/gift-card

On the Structured Testing Tool getting " "@type": "Product",

I have having two issues

Which file i can change and also where i can find the file and what name I can give " product" to fix the issue.

Any help Appreciated.

 

0 Likes
Highlighted
Tourist
23 0 2

Hi Geoff

Same issue my side - when I was still using the Supply theme then adding this to my theme.liquid removed the JSON data outputted by Shopify Product Reviews:

<script>
var SPRCallbacks = {
onProductLoad: function( e ) {
$('#shopify-product-reviews [type="application/ld+json"]').remove();
},
onReviewsLoad: function( e ) {
$('#shopify-product-reviews [type="application/ld+json"]').remove();
}
}
</script>

I've since moved to the paid Warehouse theme and no matter what I do this workaround doesn't work for me anymore and I'm stuck with the Shopify Product Review JSON messing up my metadata causing my reviews to no longer appear in my Google rich snippets.

Not sure if anyone has any ideas?

0 Likes