Hide product price

  • Please can you help,

    I have a website which the general public can’t buy the products without registering and being authorised first (the customer needs legal permission to be able to purchase). They can see the products with out the prices however.

    We can’t show the product price in Google rankings at all, but we still need our products to be found, is there a way to hide the price element for a woocommerce product or do I have to turn off Rich Snippets for all products (and would that work)

    many thanks Vicky

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    It is possible to remove certain properties from the rich snippet. You can add the following code to your theme’s functions.php file to remove the price:

    /**
     * Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
     unset($entity['offers']['price']);
     return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Thank you Michael, very much appreciated

    Thank you Micheal, very much appreciated.

    Brilliant! Just what I need, great timing!

    To confirm, does this code only remove the price from the search engine listing?

    I can still see the price in edit product/Rank Math and wanted to check.

    Many thanks!

    Hi @support90,

    I am glad that this did the trick 🙂

    @sarahrobinson yes this will only remove the price from the rich snippet and not the actual product.

    I hope this info helps. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this ticket.