product:price:amount for variable products

#44653
  • Resolved Lars
    Rank Math free

    Hello Rankmath people!

    Thanks for making such a wonderful plugin!

    I just wanted to inform you guys about a potential bug/undesirable behaviour.

    On our variable product pages, the property product:price:amount is always showing the lowest price variable.

    This is a problem for us with Google Merchant because it confuses Google when indexing all variations of a product and they are often rejected.

    I have managed to remove the product:price:amount property using

    add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $content ) {
        global $product;
        return '';
    });

    But of course it would be more desirable if the price followed each variation’s price.

    The way we distinguish between each variation is by using the variable attribute as a parameter in the product URL, for example: https://purelyprofessional.dk/shop/hair-repair-2/?attribute_vaegt=1000%20ml. (large size)

    But no matter what variation we tell Google to index, the product:price:amount is always showing the lowest variation price.
    This results in our products often being rejected by Google Merchant, but hopefully removing it will mitigate this.

    Thanks!


    Lars

Viewing 1 replies (of 1 total)
  • Todd
    Rank Math free

    Hi Lars,

    Thank you for contacting Rank Math today.

    You can use the following code snippet to customize the product snippet data and assign a new offer price to your products:

    /**
     * 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_{$schema_type}", function( $entity ) {
     return $entity;
    });

    Please take a look at this page for more info on this:

    Rank Math Filters for developers

    To show price inc VAT in the schema data, please add below filter code in your theme’s functions.php file:

    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
        global $product;
        $entity['offers']['price'] = wc_get_price_including_tax( $product );
        return $entity;
    });

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    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 1 replies (of 1 total)

The ticket ‘product:price:amount for variable products’ is closed to new replies.