Disable Price and stock Rich Snippet

#85065
  • Resolved Desmond Ng
    Rank Math free

    I remember before this, we can define the individual field that wants to be shown on rich snippets for WC products. But in the newer version, there’s no longer this option. The reason why I want to disable the RC is because I want to only show my price to logged in user. I have already enabled only logged in user will be able to see the price, but somehow, i can still see some (not all) products having te price on SERP. How do I stop this from happening?

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

    Thank you for contacting Rank Math.

    The Instock and Price in your snippets are generated from the availability, lowPrice and highPrice properties in your product schema. Other than the lowPrice, the others are recommended, not required properties, you can check that here: https://developers.google.com/search/docs/data-types/product. With this in mind, you can modify the product schema to only show the lowPrice and hide the availability. You can use this filter to achieve this:

    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        return $entity;
    });

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    ​​​​​​​

    Hi Micheal,

    I want to hide the price and availability completely on SERP. How can I use the snippet to do that?

    Also since Google already has the ich snippet displayed, I assume if I enter the code snippet now, after the next crawl, Google will honor and remove the price and availability?

    Hello,

    Please try the following code:

    
    /**
     * Filter to mod product schema.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if ( isset( $entity['offers']['availability'] ) ) { 
    		unset( $entity['offers']['availability']);
    	}
        if ( isset( $entity['offers']['highPrice'] ) ) { 
    		unset( $entity['offers']['highPrice']);
    	}
        return $entity;
    });
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Disable Price and stock Rich Snippet’ is closed to new replies.