How to remove WooCommerce structured data from Google snippet

woo expert

It’s great that WooCommerce adds the main structured data to the products so that they are then displayed in the rich snippets of Google and other search engines.

Displaying these rich results usually brings a competitive advantage in SERPs, both in CTR and conversions.

But, it’s not always what you’ll want. Sometimes you’ll prefer to hide some or all of the structured WooCommerce product data, and if that’s your case, here’s how to do it.

How to remove all structured data from WooCommerce products

To remove all the structured data that WooCommerce generates for products by default you must add the following code:

/* Remove structured data WooCommerce products */ function wphelp_remove_structured_data_woo_products( $types ) { if ( ( $index = array_search( 'product', $types ) ) !== false ) { unset( $types[ $index ] ); } return $types; } add_filter( 'woocommerce_structured_data_type_for_page', 'wphelp_remove_structured_data_woo_products' );
Code language: PHP (php)

How to remove structured price data from WooCommerce

To remove only the structured data related to prices the code would be this one:

/* Remove structured data WooCommerce prices */ function wphelp_remove_structured_data_woo_prices( $markup_offer, $product ) { $markup_offer = array( 'availability' => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ), 'url' => get_permalink( $product->get_id() ), 'seller' => array( '@type' => 'Organization', 'name' => get_bloginfo( 'name' ), 'url' => home_url(), ), ); return $markup_offer; } add_filter( 'woocommerce_structured_data_product_offer', 'wphelp_remove_structured_data_woo_prices', 10, 2 );
Code language: PHP (php)

How to remove structured inventory data from WooCommerce

To remove only the part that indicates if the product is in stock, this would be the code:

/* Remove structured data WooCommerce inventory */ function wphelp_remove_structured_data_woo_inventory( $markup_offer, $product ) { unset( $markup_offer['availability'] ); return $markup_offer; } add_filter( 'woocommerce_structured_data_product_offer', 'wphelp_remove_structured_data_woo_inventory', 10, 2 );
Code language: PHP (php)

How to remove structured data from WooCommerce ratings.

To remove everything related to product ratings, including star ratings, use this code:

/* Remove structured data WooCommerce ratings */ function wphelp_remove_structured_data_woo_ratings( $markup, $product ) { unset( $markup['aggregateRating'] ); return $markup; } add_filter( 'woocommerce_structured_data_product', 'wphelp_remove_structured_data_woo_ratings', 10, 2 );
Code language: PHP (php)

And that should cover everything related to the structured data of WooCommerce products.

But don’t expect Google to reflect the changes immediately in their searches, it may take several months to reflect the new snippets.

If you want to know how and where to paste these codes and others see this simple and quick guide:

How and where to paste PHP, JS, CSS codes and functions you find around in WordPress

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published.

Scroll to Top
Skip to content