How to hide WooCommerce product price from Google search
Do you want to remove price and stock information from Google searches? You’ve come to the right place. In this guide, we’ll show you how to hide the WooCommerce product price and stock info from Google.
Google Rich Snippets
E-commerce has had a significant impact on our shopping habits. Now we don’t need to go to a physical shop and explore for hours and hours. Instead, we can search for our desired product on Google and order it from a plethora of stores online.
Platforms such as WooCommerce have allowed everyone to create an online store and sell their products to customers all over the world. With this rise in online stores, search engines like Google also decided to up their game to provide their users with the best matching results.
With the user intent in mind, Google has introduced rich snippets. Rich snippets, also known as rich results, are highlighted search results that include valuable details such as reviews, price, list, tables, and so on. This information appears directly on the search page so users can find what they want even without clicking on the website link.
If you have an online store, you’ll know that SEO is of prime importance. WooCommerce acknowledges that and gives special attention to SEO, so it includes all rich snippets that appear on Google search results by default. Things such as your product rating, stars, reviews, price, and stock information are all displayed in your product’s search result as shown below:
Rich Snippets can be tricky for store owners
Although these snippets are useful for the end-user, you (as a store owner) might want to hide some of that information, especially the price and stock availability. That’s why having the option to hide those details can help you make the most of your store.
Let’s have a look at some of the reasons why you might want to remove the price and stock availability of your products from Google and how you can achieve that in WooCommerce.
Why Remove WooCommerce Product Price from Google?
While allowing rich snippets is good for SEO, there are some conditions where it may be a good idea to exclude some details such as price and stock status. Let’s discuss a few reasons why you should hide the WooCommerce product price and stock information from Google.
First, if users see all the information directly on the search results, they may decide not to visit your site. So to ensure that they visit your store, you may want to remove some of this information.
For example, let’s say one of your products is currently out of stock. Even though you may allow your shoppers to buy the product or create an alert when the item is on stock again, users may not know that and avoid going to your store altogether. To avoid such a scenario and make the customers visit your store and have a look at the options they have to buy that product or different alternatives, you should hide the price and stock information of your product WooCommerce from Google search.
Moreover, you don’t want your customer’s decision to be price-based only. There are chances that your product does not fall in the price range of the customer, and they decide against it. In such a case, you would like your customer to consider all of the product’s features before making a final decision. Additionally, you may offer a special deal for first purchasers but shoppers won’t know that until they visit your site.
On top of that, you may have member-only products and don’t want to disclose information about price and stock to non-members. Therefore, you must hide those details from the product page as well as Google search.
Finally, if someone visits your site, you have more chances of them joining your email list if they like your site or if you offer them a deal or interesting content for example. Additionally, if someone goes to your store, then you can retarget them with relevant ads to bring them back.
Now that we better understand why removing the product price and stock information from Google searches can be a good idea, let’s see how to do it.
How to Hide WooCommerce Product Price and stock information from Google search
Hiding the product price and availability from Google searches is quite easy. Even though it involves a bit of coding, the script is very short and doesn’t require any coding skills. Just follow the steps in order and you should be good to go.
Before you start
As we’ll edit some core fields, before we start we recommend you create a child theme. Even though you can make changes to the core files of the parent theme, it’s not a recommended practice because any changes will be overridden every time you update the theme. That means that you’ll lose all the customizations every time there’s an update which can be a huge issue. Additionally, you have to be extra careful when working with the parent theme as a single misplaced comma or a semi-colon can break your entire site.
That’s why we highly recommend you use a child theme to add customizations to your website. By implementing a child theme, all your modifications are separated from the parent theme and will remain even after updates. If you don’t know how to create a child theme, check out this guide or use one of these plugins.
With that said, let’s jump into the process to remove product price and stock information from Google.
Step 1: In your WordPress admin dashboard, go to Appearance > Theme Editor.
Step 2: Then select your current active theme and open the functions.php file of your child theme. Paste the following code snippet at the end of the file and click Update File to save the changes.
function wc_remove_some_structured_data( $markup ) {
unset( $markup['offers'] );
return $markup;
}
add_filter( 'woocommerce_structured_data_product', 'wc_remove_some_structured_data' );
That’s it! You’ve hidden the price and stock information from Google search.
But what if you want to remove even more information from the search results? Let’s see how to do it.
How to remove all information from Google search
If removing the price and stock information isn’t enough, you can take it a step further. If you want to remove all the information displayed in the rich snippets, simply copy the following code and paste it at the end of the functions.php file of your child theme.
function remove_output_structured_data() {
remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // Structured data from frontend pages
remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // Data from emails
}
add_action( 'init', 'remove_output_structured_data' );
Congratulations! You have successfully hidden all the WooCommerce structured data from Google searches.
It’s worth noting that this will remove your products’ information from the search results but not from your store. Now, let’s see how to hide products from your store.
How to hide specific products from Google search
To remove specific products from Google search, you should use the wc_get_product()->get_id(); function to get the IDs of the items you want to hide.
For example, you can use the following code to remove the product with ID 123:
function wc_remove_some_structured_data( $markup ) {
if (wc_get_product()->get_id()==123){ //poduct ID
unset( $markup['offers'] );
return $markup;
}
else{
return $markup;
}
}
add_filter( 'woocommerce_structured_data_product', 'wc_remove_some_structured_data' );
To hide several products at the same time, you need to create an array with the item IDs and a loop.
BONUS: How to Hide WooCommerce Products
WooCommerce is a powerful plugin that allows you to manage your online store in multiple ways. It enables you to create, edit, manage and update your products effortlessly any time you want.
Apart from this, it provides you with an option to hide a product temporarily in your store. There are several reasons for this:
- The item is out of stock
- You want to stop selling the product for some time
- You’re launching a new product so you want to hide it until the launch date
In either case, WooCommerce offers an easy way to hide your product from your store. Let’s have a look at how to do it.
Before we start, let’s have a look at how our WooCommerce shop page looks before removing one of our products.
Now, let’s see how to hide the Beanie with logo from our store.
Step 1: First, go to the WordPress admin dashboard and navigate to the Products page. Hover over the product you want to hide (Beanie with logo in our case) and click Edit.
Step 2: On the ‘Edit Product‘ page, go to the publish section on the far right, locate the ‘Catalog Visibility‘ option, and press Edit.
Step 3: From the dropdown menu, select ‘Hidden‘ and click OK. Then, hit the ‘Update‘ button to save changes.
To make sure that everything worked properly, let’s check our store frontend. As you can see in the image above, the Beanie with logo doesn’t appear anymore.
That’s all! Your product is now hidden from your WooCommerce store!
How to hide prices from your WooCommerce store
Another interesting alternative is to hide prices from your store. You can do that in 2 different ways:
- With plugins
- Programmatically
For example, to hide all the prices, simply paste the following code in the functions.php file of your child theme.
add_filter( 'woocommerce_get_price_html', 'QuadLayers_remove_price');
function QuadLayers_remove_price($price){
return ;
}
This is just one example but there are many other things you can do. For more information about this, check out our complete guide on how to hide prices in WooCommerce.
Conclusion
All in all, Google’s rich snippets are great for users but may not be that good for store owners because they may prevent customers from visiting their stores. That’s why in this guide, we’ve seen different situations in which removing the product price and stock information from Google search can be a good option:
- To avoid users making decisions based only on price
- Because you have member-only products and don’t want to disclose information about price and stock to non-members
- To be able to retarget users who visit your site with offers and special deals
- Because if users have all the product information in the search results they may decide not to visit your store
In this tutorial, we’ve seen different ways to hide the WooCommerce product price and stock information from Google searches. Additionally, you’ve learned how to remove all structured data from the rich snippets, how to remove prices, and how to hide products from your store.
Have you removed your products’ prices from Google search results? Do you know any other ways to do it? Let us know in the comments section below.
9 Comments
Add comment Cancel reply
You must be logged in to post a comment.
Hi !
Nice tuto !!
Your code allow to hide price from google for all products, but how can I do this for specific products, not all ?
I have part of my catalogue purchasable directly, and I don’t mind if google display the price.
But I alose have some products accessible only on quote : price are not display on the website, but they are through a google search… I want to hide this kind of products, but only them.
Is that possible ?
Respectfully,
Lx.
Hey Alex.
you can edit the script and add an if() conditional. So it will be applied only to products you want, depending on their ID’s
Use this wc_get_product()->get_id(); to get ID of products.
Something like this might work:
function wc_remove_some_structured_data( $markup ) {
if (wc_get_product()->get_id()==123){ //poduct ID
unset( $markup[‘offers’] );
return $markup;
}
else{
return $markup;
}
}
add_filter( ‘woocommerce_structured_data_product’, ‘wc_remove_some_structured_data’ );
To apply on several products, create an array and loop
I pasted the code at the end of functions.php to remove price and stock status from google search results but it is still showing. See screenshots. https://www.flickr.com/photos/194458095@N05/?
Hi Carole,
Please try this one instead and let us know if it works.
add_filter( ‘woocommerce_structured_data_product_offer’, ‘__return_empty_array’ );
Thanks
Hello , thank you for your help, i did all your recomendations and prices dissapear but after some time have returned. Is there anything else I can do to avoid this?
Hi Juanny, please check any recent updates to WordPress or your theme. These updates might have overridden the changes.
Please make sure to use a child theme to add custom code snippets. Alternatively, you can also use the Code Snippets plugin. This way, your changes will remain saved even after the updates.
Hello, I have tried this code above and the other you offered.
add_filter( ‘woocommerce_structured_data_product_offer’, ‘__return_empty_array’ );
Still google is showing one of our price points.
We have 3 price breaks on our products and you are only allowed to view them then logged in, but unfortunately people are seeing them in google searches now. Is there any other way to stop google from finding our product prices?
How long is it supposed to take if I used the code above for google search to stop showing the price?
Hello Feliciaa,
It can be challenging to identify the exact reason why the code is not functioning as expected without thoroughly examining all possible causes.
Please ensure that you are accurately following each step of the process. You could also attempt using the alternative filter provided below to see if it resolves the issue:
add_filter( 'woocommerce_structured_data_product_offer', function(){return [];}
If this solution does not work, it may be necessary to seek assistance from a qualified technical expert as it is difficult to diagnose the issue without more information.
Thanks!
Hello. I Updated this. But still showing price in google search page. How much time it need to work?