Support » Plugin: WooCommerce » Removing price and stock rich snippets from Google Search

  • Resolved davinderschiedel

    (@davinderschiedel)


    The link should take you to one of our products.

    Adjustable Register Plate Top – Flexible Liners – Schiedel Product …
    https://www.schiedel.com › … › Adjustable Register Plate Top – Flexible Liners
    £66.12 to £108.18 – ‎In stock

    Snippets adds the price and stock. Is there a way to stop Google seeing this, even coding the site to remove the snippets.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    You can use the woocommerce_structured_data_product filter to remove some structured data: https://github.com/woocommerce/woocommerce/blob/5bec3b229fd3fb16f144035efb9007473465b016/includes/class-wc-structured-data.php#L272

    davinderschiedel

    (@davinderschiedel)

    Thanks. In the meanwhile, I found this code which stripped it all out:

    function remove_output_structured_data() 
    { 
    remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // Frontend pages 
    remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // Emails 
    } 
    add_action( 'init', 'remove_output_structured_data' );
    

    The one you’ve shown, how would I just remove lowprice and highprice and whether it shows in stock? And is it as simple as placing the resulting file in the woocommerce/includes/ directory as a class-wc-structured-data.php file?

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Using the filter I posted will be similar to the snippet you are using to remove all data. So something like this:

    
    function wc_remove_some_structured_data( $markup ) { 
    	unset( $markup['offers'] )
    	return $markup;
    } 
    add_filter( 'woocommerce_structured_data_product', 'wc_remove_some_structured_data' );
    
    davinderschiedel

    (@davinderschiedel)

    That’s perfect. Just what I needed to remove certain Rich Snippets / Schema. I’ve used your code.

    Much appreciated.

    Hi,

    As on mobile phone, the image detected with a “product” label showing the product pricing if search on Google.
    Is there any way to hide/prevent the price from being shown from google search with mobile ?

    https://prnt.sc/jrh5k7
    https://prnt.sc/jrh60r

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Removing price and stock rich snippets from Google Search’ is closed to new replies.