-
I have a variable product with 3 color (black, brown, blue).
Brown is out of stock, the other 2 are in stock.Despite the brown out being out stock, google crawler gave an error, saying it detected “in stock” schema.
I checked the page source and discovered that there is only one global availability, instead of 3 (one for each color)How do I get rank-math to show availability for each variant?
Thank you
-
Hello,
Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.
Can you please share the affected URL with us so we can further check it on our end?
Looking forward to helping you with this one.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
With variables products, the different offers for each variation are only generated if the price changes.
This is because the only required property by Google is the price, and if that doesn’t change there’s no need to generate multiple offers on the Schema markup.
https://developers.google.com/search/docs/advanced/structured-data/productIf you add different prices to the products you can then see the different offers and different stock statuses being applied to each product.
Hope this helps clarify your doubts.
Don’t hesitate to get in touch if you have any other questions.
Hello Miguel,
My product comes in 3 colors. Each priced the same, but with different stock to each color.
I’m receiving an error in my google merchant center because of this matter.
In merchant center, I have each color as a separate product.
How do I create different offers for each variant despite them having the same price? (Because each have their own separate inventory stock)
Thank you Miguel
Hello,
At the moment the only way to have multiple offers for products with the same price would be to implement the following filter:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) { if ( ! is_product() ) { return $entity; } $product = wc_get_product( get_the_ID() ); if ( ! $product->is_type( 'variable' ) ) { return $entity; } $variations = $product->get_available_variations(); if ( ! empty( $variations ) ) { $offers = []; foreach ( $variations as $variation ) { $price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true ); $offers[] = [ '@type' => 'Offer', 'description' => strip_tags( $variation['variation_description'] ), 'price' => $variation['display_price'], 'priceCurrency' => get_woocommerce_currency(), 'availability' => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock', 'itemCondition' => 'NewCondition', 'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31', 'url' => $product->get_permalink(), ]; } } $entity['offers']['offers'] = $offers; return $entity; } );Please note that this needs to be configured and changed according to your very own requirements.
Hope this helps solve your issues.
Don’t hesitate to get in touch if you have any other questions.
After applying the new filter, I received 3 warnings when checking the new schema.
You can see it here
The warning says: “The property offers is not recognized by the schema (e.g. schema.org) for an object of type Offer.”
Plus, shouldn’t each variant offer include the SKU of the variant? So google can identify which variant is which offer.
I found a format after some reading online. It might be usable for this case. I just don’t know how to change it to a filter/snippet.
{
“@context”: “http://schema.org/”,
“@type”: “Product”,
“name”: “Clarks Falalala Shoes for Men”,
“image”: “https://example.net/shoes/clarks-falalala.jpeg”,
“description”: “A great comfortable walking shoe, carried in sizes 9-11, but now size 11 isn’t in stock”,
“offers”: [ {
“@type”: “Offer”,
“sku”: “QWERTYSHOE-9”,
“price”: 45.99,
“priceCurrency”: “EUR”,
“availability”: “InStock”
},{
“@type”: “Offer”,
“sku”: “QWERTYSHOE-10”,
“price”: 45.99,
“priceCurrency”: “EUR”,
“availability”: “InStock”
},{
“@type”: “Offer”,
“sku”: “QWERTYSHOE-11”,
“price”: 45.99,
“priceCurrency”: “EUR”,
“availability”: “OutOfStock”
} ]
}Hello,
As was mentioned in the previous reply, that was a placeholder filter to give you an idea of how this filter could be implemented to fetch the data for each variation.
If you need to fetch additional information or remove unnecessary information you’ll need to modify that filter to suit the needs of your website.
We also looked at the link you sent and couldn’t see any warnings or errors on that page.
In case you don’t feel comfortable with coding we recommend that you hire a developer to provide this high level of customization.
Don’t hesitate to get in touch if you have any other questions.
Hello Miguel,
The warning is gone since I temporarily disabled the snippet containing your filter code.
If I purchase Rank Math, will you / your team help me resolve this matter (provide high level customization to the schema, as you’ve mentioned) ?
Hello,
This level of customization usually falls outside the scope of Rank Math support.
Having said that, if you could create some WP & FTP credentials to your website or a staging website we can take a closer look and try a couple of modifications to have the Schema on variable products display the values you mentioned previously.
Looking forward to helping you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Thank you so much Miguel. I’ve added the staging site information to the sensitive data. I look forward hearing from you.
Hello,
Thank you for getting back to us and sorry for the delayed response.
We have created a filter on your website that outputs the SKU and all the other necessary information for the variations even if the price is the same.
That is included in the Snippets section with the name “Rank Math – Variable Products” so you can check what the code looks like.
Hope this helps solve your issues.
Don’t hesitate to get in touch if you have any other questions.
I’ve used the snippet in my main site and let me observe Google crawlers feedback after this and I’ll update you if the problem is solved.
Thank you again, Miguel
Hello,
Thank you for the update.
Sure, let us know how this goes.
Meanwhile, please don’t hesitate to contact us anytime if you have other questions to assist you further with anything else.
Looking forward to helping you.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.
The ticket ‘variable product availability schema’ is closed to new replies.