Google Test Tool and Search Console show error on WooCommerce products

A few customers have reported today that Google search console as well as Googles Structured Data Test Tool brings up the following error: One of offers or review or aggregateRating should be provided. In this post I want to investigate a little further what’s happened.

How it was till today

In SNIP there is a field type called “WooCommerce: offers”. It outputs structured data for an Offer. Typically the Offer-Schema will be inherited into the Product-Schema.

In the past it looked like this:

{
    "@context": "http:\/\/schema.org",
    "@type": "Product",
    "name": "Hand Towels",
    "offers": [
        {
            "@context": "http:\/\/schema.org",
            "@type": "Offer",
            "availability": "http:\/\/schema.org\/InStock",
            "priceCurrency": "USD",
            "price": "7.40",
            "itemOffered": {
                "@context": "http:\/\/schema.org",
                "@type": "IndividualProduct",
                "url": "https:\/\/www.thetoweldepot.com\/bulk\/15-x-25-white-hand-towels-2-25-lbs-100-cotton\/"
            }
        }
    ]
}

As you can see, the itemOffered property inherits a sub-schema of IndiviualProduct.

If you have a variable product in WooCommerce the output would have multiple Offer-Schemas:

{
    "@context": "http:\/\/schema.org",
    "@type": "Product",
    "name": "Hand Towels",
    "offers": [
        {
            "@context": "http:\/\/schema.org",
            "@type": "Offer",
            "availability": "http:\/\/schema.org\/InStock",
            "priceCurrency": "USD",
            "price": "7.40",
            "itemOffered": {
                "@context": "http:\/\/schema.org",
                "@type": "IndividualProduct",
                "name": "Red Colored Hand Towel"
            }
        },
{
            "@context": "http:\/\/schema.org",
            "@type": "Offer",
            "availability": "http:\/\/schema.org\/InStock",
            "priceCurrency": "USD",
            "price": "8.40",
            "itemOffered": {
                "@context": "http:\/\/schema.org",
                "@type": "IndividualProduct",
                 "name": "Blue Colored Hand Towel"
            }
        }
    ]
}

How it should be (in the future)

So now Googles Test Tool brings up an error for exactly that IndividualProduct-Schemas. It seems that Google wants you to add all the recommended properties that are needed for a Product (you can see a list here). However that doesn’t really make much sense (at least in case of WooCommerce) because all the properties would be doubled.

So the solution to this is to remove the IndividualProduct sub-schemas from the Offer-Schema for a single product:

{
    "@context": "http:\/\/schema.org",
    "@type": "Product",
    "name": "Hand Towels",
    "offers": [
        {
            "@context": "http:\/\/schema.org",
            "@type": "Offer",
            "availability": "http:\/\/schema.org\/InStock",
            "priceCurrency": "USD",
            "price": "7.40"
        }
    ]
}

And add an AggregateOffer-Schema to variable products:

{
    "@context": "http:\/\/schema.org",
    "@type": "Product",
    "name": "Hand Towels",
    "offers": {
        "@context": "http:\/\/schema.org",
        "@type": "AggregateOffer",
        "lowPrice": "7.40",
        "highPrice": "8.40",
        "priceCurrency": "USD",
        "offerCount": 2,
        "url": "http:\/\/wp-buddy.test\/product\/variable-product\/"
    },
}

Contrary to Google’s own reference, the “itemOffered” property no longer seems to be a recommended.

So the above changes will be available in version 2.14.5 of SNIP.