Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Either offers review or aggregateRating should be specified #22896

Closed
waqarabro opened this issue Feb 27, 2019 · 122 comments · Fixed by #22925
Closed

Either offers review or aggregateRating should be specified #22896

waqarabro opened this issue Feb 27, 2019 · 122 comments · Fixed by #22925

Comments

@waqarabro
Copy link

Hello guys, I am sure you must be facing the same issue that I am updating in this thread. It is a recent Google Console Enhancement that throws a huge number of errors in the console. Take a look at screenshots in the end. I would be highly grateful if you guys help to fix this issue.

I am looking for a solution to fix this issue asap on my website. It affects almost all the products of my site. It will be great if you guys tell whether Woocommerce next updates gonna fix it for all store owners.

I have gone through this link #22842 that discusses the solution but probably not a solution just a discussion. After going through this link, i found a code that needs to be added in WOOCOMMERCE/INCLUDES/STRUCTURED DATA PHP file. I did that either and found it useless.

Will appreciate if the solution is listed down step by step so that everyone could utilize it and fix the issue. P.S most of the Woocommerce store owners are not developers and code friendly.
1
2
3

@waqarabro waqarabro changed the title Either offersreview or aggregateRating should be specified Either offers review or aggregateRating should be specified Feb 27, 2019
@AdamHashim

This comment has been minimized.

@itsgauravjain22
Copy link

itsgauravjain22 commented Feb 28, 2019

Same issue have been faced by my my store recently. I have attached the part of google structured data testing screenshot:

1

2

@AmeliaAkh

This comment has been minimized.

@mikejolley

This comment has been minimized.

@JimmyRaz

This comment has been minimized.

@mikejolley

This comment has been minimized.

@waqarabro

This comment has been minimized.

@waqarabro

This comment has been minimized.

@itsgauravjain22

This comment has been minimized.

@bekarice
Copy link
Contributor

Chiming in here after the Slack dev chat :)

From the research I've done on structured data in the past, structured data is designed to tell you about the information directly being presented on a page. Google notes this:

You should not create blank or empty pages just to hold structured data; nor should you add structured data about information that is not visible to the user, even if the information is accurate.

When generating structured data, WooCommerce includes a lot of data that's not shown in the product archive, so this data should not be present according to the guidelines.

So what about limiting the structured data in archives -- should we do that or remove it completely?

Google indicates in a few places that structured data should not be included in an archive that lists links to full listings.

Don’t mark up a page that lists all engineering jobs in Mountain View, CA, with links to individual job pages.
Source

Use markup for a specific product, not a category or list of products. For example, “shoes in our shop” is not a specific product. See also our structured data guidelines for multiple entities on the same page.
Source

A category page listing several different products (or recipes, videos, or any other type). Each entity should be marked up using the relevant schema.org type, such as schema.org/Product for product category pages. However, if one item is marked, all items should be marked. Also, unless this is a carousel page, the marked items should not link out to separate details pages.
Source

(Emphasis mine on this last one.) So for WooCommerce archives, given they list all products and link out to full details pages, they should not be marked up. My vote is to remove this line for generated structured data on archives.

@AmeliaAkh
Copy link

@bekarice
Hello I don't know much about this, but is it possible to just remove it? Should we also remove the code snippet that was given here before?

With kind regards, Amelia

@bekarice
Copy link
Contributor

this should work, but I haven't tested it, so use with caution:

remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10 );

@AmeliaAkh

This comment has been minimized.

@AlCalder

This comment has been minimized.

@waqarabro

This comment has been minimized.

@itsgauravjain22

This comment has been minimized.

@TimBHowe
Copy link
Contributor

As discussed in the Slack Dev Chat today removing the product schema markup from the Shop/Product Category pages seems to be the best solution.

To do that you can add the following code to your themes function.php file.

/**
 * Remove the generated product schema markup from the Product Category and Shop pages.
 */
function wc_remove_product_schema_product_archive() {
	remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10, 0 );
}
add_action( 'woocommerce_init', 'wc_remove_product_schema_product_archive' );

If you had previously added the other suggested snippets from
#22842 (comment)
#22842 (comment)
they can be removed, but the one above should prevent them from running. As always if you are not comfortable editing the code please consult a developer.

I'm going to try and work on PR to fix the issue for a future release. Hope this helps.

@JimmyRaz

This comment has been minimized.

@AmeliaAkh

This comment has been minimized.

@waqarabro

This comment has been minimized.

@AmeliaAkh

This comment has been minimized.

@waqarabro

This comment has been minimized.

@AmeliaAkh

This comment has been minimized.

@waqarabro

This comment has been minimized.

@AmeliaAkh

This comment has been minimized.

@thestronggoat

This comment has been minimized.

@crypto1008

This comment has been minimized.

@waqarabro
Copy link
Author

waqarabro commented Mar 8, 2019

You need to also add brands to the products :)

The global ID warning is new, it wasn't in the validator last week. We won't be pushing an update out for that yet so you'll need to extend the schema manually if you want those warnings gone. Google makes change to these requirements frequently.

https://support.google.com/merchants/answer/160161?hl=en-GB

Bro i have added brands and tested either. SEE YOURSELF

Hey Jolley i tried to add a plugin which added "Brand" as taxonomy perhaps. Please look at the images, it is still throwing errors.

capture
capture1

link to test: https://dresses.com.pk/shop/anaya-by-kiran-chaudhry/anaya-by-kiran-chaudhry-dress/

can you tell why is it still throwing error?

@mikejolley
Copy link
Member

sigh you are using YITH brands. I don't even know if that adds schema. The WooCommerce.com does. Contact the developer.

@mitchellkrogza
Copy link

mitchellkrogza commented Mar 8, 2019

After re-reading the thread, the fix from @TimBHowe does indeed solve the problem. #22896 (comment)

@JohnDost
Copy link

JohnDost commented Mar 8, 2019

Check this one #22896 (comment). This could be the solution to your Brand error, as it does add the brand into the schema. I am not sure if you can see the actual comment via the link so I will paste the code.

/**

  • Filter the woocommerce_structured_data_product_limit if statment to always add the full structure.
  • @param boolean $is_archive_page returns true or false based on is_product_taxonomy() || is_shop() WooCommerce Conditionals.
  • @return boolean Return false to force the function to continue and not limit the product data on the archvie page.
    */
    function wc_unlimit_product_structed_data( $is_archive_page ) {
    return false;
    }
    add_filter( 'woocommerce_structured_data_product_limit', 'wc_unlimit_product_structed_data', 10, 1 );

/**

  • Add items to the product schema markup.

  • @param array $markup Array of the product scheme markup.

  • @param WC_Product $product Product data (default: null).

  • @return array Altered $markup.
    */
    function wc_add_product_structed_data( $markup, $product ) {
    // Add the brand to the product schema markup.
    $markup['brand'] = '';

    // If is it a product archive page add the URL to the product schema markup.
    if ( is_product_taxonomy() || is_shop() ) {
    $markup['url'] = get_permalink( $product->get_id() );
    }

    return $markup;
    }
    add_filter( 'woocommerce_structured_data_product', 'wc_add_product_structed_data', 10, 2 );

@bondimedical3
Copy link

bondimedical3 commented Mar 12, 2019

@mikejolley I have just received the Validation results from Google Search console and the latest update does NOT fix the errors.
PS - all my structured data, reviews, ratings etc have now disappeared from Google search results.

@mohamm4d
Copy link

mohamm4d commented Mar 12, 2019

@mikejolley I have just received the Validation results from Google Search console and the latest update does NOT fix the errors.
PS - all my structured data, reviews, ratings etc have now disappeared from Google search results.

hi @mikejolley
which Errors still remaining ?

As discussed in the Slack Dev Chat today removing the product schema markup from the Shop/Product Category pages seems to be the best solution.

To do that you can add the following code to your themes function.php file.

/**
 * Remove the generated product schema markup from the Product Category and Shop pages.
 */
function wc_remove_product_schema_product_archive() {
	remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10, 0 );
}
add_action( 'woocommerce_init', 'wc_remove_product_schema_product_archive' );

If you had previously added the other suggested snippets from
#22842 (comment)
#22842 (comment)
they can be removed, but the one above should prevent them from running. As always if you are not comfortable editing the code please consult a developer.

I'm going to try and work on PR to fix the issue for a future release. Hope this helps.

thank you @TimBHowe , I test this but still got same result in google schema test tool . ;(

I got more than 7000 errors and my ranking are dropping . I wish woocommerce / wordpress had stable release (with no major changes )

@Laurentyzy
Copy link

Same here, "Either "offers", "review", or "aggregateRating" should be specified" errors are not fixed after validation on category pages. Above solution don't work for me.

@fdanell
Copy link

fdanell commented Mar 12, 2019

@bondimedical3 @Laurentyzy double check that your theme doesn't add "schema" stuff. When I looked at the structured data of my product page, there I had two quite similar product-objects. one of them still had the error after upgrade but it wasn't woocommerce fault, it was in the theme.

@bondimedical3
Copy link

I am using the Storefront theme. To my knowledge it doesn't add any structured data.

@bondimedical3
Copy link

bondimedical3 commented Mar 13, 2019

@mikejolley I take back what I said about the update. It appears the errors started to reduce yesterday in my Google Search Console.

Github

@fdanell
Copy link

fdanell commented Mar 13, 2019

@bondimedical3 I think i'ts possible that you have 2 schema objects on your products. you have 7 warnings on some and 14 warnings on some which is an exact double, which is what you would see if some warnings are the same in one if two objects. If you paste one of your product URL in search console you will see the warnings, clic on the warnings and you will see where they stem from in the url. <script type="application/ld+json"> is probably woocommerce, and in my case i had "itemtype="http://schema.org/Product" on a div containing the product that produced error and warnings, this tag was added by my theme producer, it wasn't default. I later omitted this tag with positive results.

@bondimedical3
Copy link

bondimedical3 commented Mar 13, 2019

@mikejolly Today I received an official email from Google that all my URLs had passed validation so in fact the latest update does fix the problem. No errors are showing in my Search Console.

PS: All my structured data, reviews, ratings etc have also started to show in Google Search results again.

@mitchellkrogza
Copy link

Some of my errors have passed validation but others not, what do we do about the remaining items marked with warnings?
Screenshot_2019-03-14_09-08-09

@JohnDost
Copy link

I do not get it either, why is the product ID missing? Shouldn't this be added in the structured-data.php? If you do not have ratings and reviews these warnings should be there. But for all the other (except brand that is explained above) are unnatural. The ID, offerCount (I guess it's for variable products) pricevalid until and availability they shouldn't be there.

@sicarioxy
Copy link

sicarioxy commented Mar 15, 2019

For availability use this one (http) let me know if it fix it:
'availability' => 'http://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),

@JohnDost
Copy link

Well the issue is that this line does exist in the update version of structured-data.php. Plus it doesn't say that the value is missing, what it says is that the value is invalid, so probably something wrong with the woocommerce code that sets in stock and outofstock.

			$markup_offer += array(
				'priceCurrency' => $currency,
				'availability'  => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
				'url'           => $permalink,
				'seller'        => array(
					'@type' => 'Organization',
					'name'  => $shop_name,
					'url'   => $shop_url,
				),
			);

@sicarioxy
Copy link

sicarioxy commented Mar 15, 2019

instead of using https://schema.org/ use http://schema.org/ see if this fix the invalid error for availability in search console ?

$markup_offer += array(
				'priceCurrency' => $currency,
				'availability'  => 'http://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
				'url'           => $permalink,
				'seller'        => array(
					'@type' => 'Organization',
					'name'  => $shop_name,
					'url'   => $shop_url,
				),
			);

@JohnDost
Copy link

JohnDost commented Mar 15, 2019

with the http passed the initial validation so I will keep an eye on it, with the https it did not pass that validation, so it could be the reason for the availability issue.

Do you have any ideas for the ID, offerCount and pricevaliduntil?

@sicarioxy
Copy link

For Brand this will fix it if you use yoast and your product category is your brand

$primary_cat_id=get_post_meta($product->id,'_yoast_wpseo_primary_product_cat',true);
if($primary_cat_id){ $product_cat = get_term($primary_cat_id, 'product_cat');

$markup['brand']   =  $product_cat->name; }

offerCount and pricevaliduntil i don't have these two errors. try to revert to default theme and do a quick check if its your theme or not.

Product ID its because of the gtin, MPN stuff. The route I am thinking is using Identifier_Exists Attribute with a value of FALSE. But I don't know how to write that code. I need to try and see if I can come up with something. If there is anyone who know how to write and implement this, please share.

@JohnDost
Copy link

As I see it for the brand thingy because it's just a warning it doesn't worth it to download a plugin, create the brand and edit each and every product to assign a brand, for example I have about 200 products on the shop it's not worth it, I mean time wise, to edit each and every product just to remove a warning that doesn't even matter SEO wise.

@mitchellkrogza
Copy link

Very true @JohnDost errors have passed validation and warnings are merely warnings and should not require any extensive fiddling or plugins just to see a clean slate in Search Console.

@JohnDost
Copy link

true, but we should fix what we can, if it worth it anyway.

@NileshKothari
Copy link

As discussed in the Slack Dev Chat today removing the product schema markup from the Shop/Product Category pages seems to be the best solution.

To do that you can add the following code to your themes function.php file.

/**
 * Remove the generated product schema markup from the Product Category and Shop pages.
 */
function wc_remove_product_schema_product_archive() {
	remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10, 0 );
}
add_action( 'woocommerce_init', 'wc_remove_product_schema_product_archive' );

If you had previously added the other suggested snippets from
#22842 (comment)
#22842 (comment)
they can be removed, but the one above should prevent them from running. As always if you are not comfortable editing the code please consult a developer.

I'm going to try and work on PR to fix the issue for a future release. Hope this helps.

Hello sir, I have already applied this code on function.php file but it did work only for "shop" Pages, It didn't work for "Product Category Pages"

@joeblowhelp
Copy link

hi, would someone be kind enough to explain or provide a tutorial or point me a to a link in which the answer is described in plain english how to fix this, i'm not a code guru i just need woocommerce to stop causing errors in google structured data testing tool. please help, anyone.

@marvinsolano
Copy link

hi, would someone be kind enough to explain or provide a tutorial or point me a to a link in which the answer is described in plain english how to fix this, i'm not a code guru i just need woocommerce to stop causing errors in google structured data testing tool. please help, anyone.

All you need to do is update to the latest version. They fixed most of the warning except Brand. It is my understanding that Woocommerce has a plugin for Brands and that should take care of it.

@WebAssen
Copy link

Hi, does anyone has any coding advice or recommendations on how to use the attribute as a Brand.
I am not using the Brand extension.

@enthusiast44
Copy link

hi, would someone be kind enough to explain or provide a tutorial or point me a to a link in which the answer is described in plain english how to fix this, i'm not a code guru i just need woocommerce to stop causing errors in google structured data testing tool. please help, anyone.

All you need to do is update to the latest version. They fixed most of the warning except Brand. It is my understanding that Woocommerce has a plugin for Brands and that should take care of it.

I am not sure why you think it is fixed? I checked today and I am receiving several errors still receiving the following

Warning Invalid value type for field "availability"
Warning Missing field "brand"
Warning Missing product ID
Warning Missing field "aggregateRating"
Warning Missing field "review"
Warning Missing field "description"

@mikejolley
Copy link
Member

This issue is resolved but as a few folks are still seeing problems I will summarize this one last time and lock comments to contributors.

  1. The fix prevents the "Either offers review or aggregateRating should be specified" error on archive pages. This was actually reported as an error in Google validator and is resolved.

  2. Missing brand is a warning, not an error, and can be added through use of a plugin such as https://docs.woocommerce.com/document/wc-brands/ - brands do not exist in WooCommerce core.

  3. Missing ID is a warning. It can be added via a plugin such as Google product feeds and has an open issue for discussion since core does not have a field suitable for this data currently Product Schema - Add global identifiers if they are defined/add a new BARCODE field to define global identifiers #22969

  4. Missing aggregateRating/ratings is a warning. If your product doesn't have reviews, of course this data is missing. WooCommerce cannot make up review content for you :)

  5. If you continue to see "Either offers review or aggregateRating should be specified" errors it's likely inline markup added by your theme. WooCommerce does not add inline schema markup - it uses JSON+LD scripts.

Thanks

@woocommerce woocommerce locked as resolved and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet