Hi,
I have some issue I didn't notice until then because it's pretty hidden and only occurs at certain circumstances:
I have a variable product with variations.
All variations have multiple warehouses.
The Main inventory is always empty (=0, manage_stock=yes), but Inventory XY has qty=5 and manage_stock=yes.
So, the variations are available in our store and can be purchased.
However, in the database, the variations are "outofstock" because only the Main Inventory status is taken here. This status inherits to the variable product (remember, all variations are "outofstock" in Main Inventory), so the variable product is "outofstock".
However, WooCommerce is using this information for their structured data (Schema.org) on the product page:
$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,
),
);
\wp-content\plugins\woocommerce\includes\class-wc-structured-data.php @line 260
So, for Google/Bing and all other crawlers, this information is taken as information if this product is generally in stock. If not, it is kicked out of Google Shopping etc.
function custom_structured_data_offer( $markup_offer, $product ) {
$markup_offer['availability'] = 'http://schema.org/InStock';
return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', array( $this, 'custom_structured_data_offer' ), 10, 2 );
This "quickfixes" the problem for me, but it is not very good though. Can you give me a good request to get the real stock status for variable products (as long you may take for fixing it in the plugin?). That would be awesome.
Thanks in advance.
Best regards,
Christoph