Hide product price

#18831
  • Resolved Victoria Hepburn
    Rank Math free

    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 7 replies - 1 through 7 (of 7 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.

    The code does not prevent the price from appearing in the snippet. Can it be for the currency exchange plugin?
    WOOCS – WooCommerce Currency Switcher
    https://www.google.com/search?q=sofia+lapenta+pa%C3%B1uelo+limona&oq=sofia+lapenta+pa%C3%B1uelo+limona&aqs=chrome..69i57j33l3.6709j1j1&sourceid=chrome&ie=UTF-8
    Thank you

    • This reply was modified 4 years, 4 months ago by Elapenta.
    Todd
    Rank Math free

    Hi Elapenta,

    I am sorry but it only works on the rich snippets generated by Rank Math.

    If you need help with anything else, please open a new support ticket here so we can help:

    https://support.rankmath.com

    We are always here for assistance.

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

The ticket ‘Hide product price’ is closed to new replies.