Liquid, JavaScript, themes, sales channels
Hi
I'm getting the following error showing against all my products in the Google search console.
Either "offers", "review", or "aggregateRating" should be specified.
Anyone seen this before / know how to resolve?
Damian
The solution for me was ultimately pretty simple.
To fix the GSC message "Either "offers", "review", or "aggregateRating" should be specified." go to edit theme -> sections -> product-template.liquid
At least on Brooklyn theme (2019 version and earlier), the code is wrapped in two overlapping schemes like this:
<div itemscope itemtype="http://schema.org/Product" id="ProductSection--{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="product-template" data-image-zoom-type="{{ section.settings.zoom_enable }}" data-enable-history-state="true" data-scroll-to-image="true">
<div itemscope itemtype="http://schema.org/Product">
some code
</div>
</div>
to get rid of the error message, delete the second line "<div itemscope itemtype="http://schema.org/product">" and the closing tag "</div>" for it. The code should look like this after you're done:
<div itemscope itemtype="http://schema.org/Product" id="ProductSection--{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="product-template" data-image-zoom-type="{{ section.settings.zoom_enable }}" data-enable-history-state="true" data-scroll-to-image="true">
some code
</div>
After you're done check to see if the errors are gone using SDTT.
Hope this helps!
Hello!
My store - https://amzsupply.com
Example product URL - https://amzsupply.com/collections/kraft-padded-envelopes/products/7-25x7-cd-size-kraft-bubble-mailer...
Theme -Warehouse
Reviews app - Shopify reviews app
Google Test Tool URL - PRODUCT
I am using Warehouse theme and Shopify reviews app.
The theme already comes with JSON_LD generation, but I disabled that to use SMART SEO. I removed {% render 'microdata-schema'%} from theme.liquid so that it doesn't duplicate SMART SEO.
Now there is a problem with JSON-LD for reviews that seem to be duplicated. I cannot find what and where to edit in the code. I have seen a similar one in this thread, but have not solved this problem.
Friends, help me with these.
I have found 4 warnings ,but iam unable to resolve it.can you please tell solution for it.
Above screenshot shows the warnings,please tell how to fix it.URL is https://www.gullylivefast.com/pages/deal-of-the-day
You can resolve everything except the reviews warnings by following the guide here: https://feedarmy.com/kb/shopify-microdata-for-google-shopping/
Make sure to cleanup your theme to remove any old code.
<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_image.src | img_url: '1024x1024' }}",
"image": "https:{{ product.featured_image.src | img_url: '1024x1024' }}",
"name": {{ product.title | json }},
"width": 1024,
"height": 1024
}
}
</script>
This is our schema script,what should be value for sku,aggregate rating,product review and product identifier.
Can you please tell how script should be changed to avoid that warnings.
This is my product-template-variable-liquid code which contains script for product.
{%- assign current_variant = product.selected_or_first_available_variant -%}
{%- 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_image.src | img_url: '1024x1024' }}",
"image": "https:{{ product.featured_image.src | img_url: '1024x1024' }}",
"name": {{ product.title | json }},
"width": 1024,
"height": 1024
}
}
</script>
{%- assign product_thumb_size = '180x' -%}
{%- assign product_zoom_size = '1800x1800' -%}
{%- assign product_image_size = '620x' -%}
{% case image_container_width %}
{% when 'small' %}
{%- assign product_image_width = 'medium-up--two-fifths' -%}
{%- assign product_description_width = 'medium-up--three-fifths' -%}
{%- assign product_image_size = '480x' -%}
{% when 'medium' %}
{%- assign product_image_width = 'medium-up--one-half' -%}
{%- assign product_description_width = 'medium-up--one-half' -%}
{%- assign product_image_size = '620x' -%}
{% when 'large' %}
{%- assign product_image_width = 'medium-up--three-fifths' -%}
{%- assign product_description_width = 'medium-up--two-fifths' -%}
{%- assign product_image_size = '740x' -%}
{% endcase %}
to this code what changes need to be done to avoid warnings
can you please tell what is the solution to resolve the warnings
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:
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:
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!@Leysam - 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 %}
@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!Looks like that code already exists in my file. I am trying to resolve following two errors in Google Console.
{%- 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>
..deleting what I wrote---
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.
Hi @Leysam,
Are you able to assist with this as its not clear when looking at our files what to do. We have the Shopify Review app.
regards
Glen
Hello @GW192 , I can help you, mind sending me an email or message where we can discuss this further?
Leysam | The Shopify Guy
- Was my reply helpful? Click Like to let me know!@Leysam what is your email? I'm new to the forum and can't see any options to contact you.
Hello @GW192
email: edwardwindtalker@gmail.com
skype: samypogs
Leysam | The Shopify Guy
- Was my reply helpful? Click Like to let me know!Hi all, I'm seeing the same error on my Product Snippets - "Either "offers", "review", or "aggregateRating" should be specified"
URL -
Hello @samarjeet86 , there's no easy fix to this, you might need to hire an expert to fix this issue.
Leysam | The Shopify Guy
- Was my reply helpful? Click Like to let me know!Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024