Hey @thimy,
I assume that you’re using AIOSEO Pro since Product schema is a feature. If so, please reach out to us at https://aioseo.com/contact since we technically aren’t allowed to help you here as a Pro customer due to the WordPress.org guidelines.
That being said, if you want to remove the price from our Product schema, I recommend that you completely remove the Product schema by changing the default graph for the WooCommerce Product post type under AIOSEO > Search Appearance > Content Types > Products > Schema. Price is a required property in Product schema so if you were to remove it, Google will no longer show rich snippet results for your products and instead throw errors in Google Search Console.
Let me know if that makes sense.
Thread Starter
thimy
(@thimy)
Hey, thanks for your answer, i understand that you want sell your Pro version but i use the free plugin.
So I looked for a way to override woocommerce schema instead of doing it through your plugin and implemented a snippet like this which works perfectly to remove “offers > prices” in schema :
function bs_product_delete_meta_price( $product = null ) {
if ( ! is_object( $product ) ) {
global $product;
}
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( '' !== $product->get_price() ) {
$shop_name = get_bloginfo( 'name' );
$shop_url = home_url();
$markup_offer = array(
'@type' => 'Offer',
'availability' => 'https://schema.org/' . $stock = ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
'seller' => array(
'@type' => 'Organization',
'name' => $shop_name,
'url' => $shop_url,
),
);
}
return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'bs_product_delete_meta_price' );
I assume that Google don’t index this part and Search console return an error but my customer sell those products in b2b and its customers do not want to see the prices displayed.
If you think there is another solution, please let me know i’m curious to try it 🙂
Hey @thimy,
Not trying to sell our Pro version, I just thought you were using it since you were asking about Product schema, which is one of our Pro features. 🙂
Anyway, that looks like a good solution to me. I would probably just completely remove the Product schema from WooCommerce in this case since Google isn’t going to use it, but otherwise this should work.