Variable products rejected by Google Merchant Center due to price discrepancies

#388464
  • Resolved An-khanh
    Rank Math free

    hello,

    We use variable products here :
    https://lesjuspaf.bio/produit/les-cures/cure-detox/

    And price is displayed through the snippets configured by rankmath, I’m looking for a solution to disable them. I tried this:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    if ( ! is_product() ) {
    return $entity;
    }

    $product = wc_get_product( get_the_ID() );
    if ( ! $product->is_type( 'variable' ) ) {
    return $entity;
    }

    $variations = $product->get_available_variations();
    if ( ! empty( $variations ) ) {
    $offers = [];
    foreach ( $variations as $variation ) {
    $price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
    $offers[] = [
    'price' => $variation['display_price'],
    ];
    }
    }

    $entity['offers'] = $offers;

    return $entity;
    } );

    But it seemingly does not help, as my variations product are still rejected.

    Do you have any idea ?

    Thanks a lot for your help

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

    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.

    It seems that you are adding Offers properties with only the price in it. You would need to insert other necessary properties such as the priceCurrency, availability and etc. Please refer to this modified code instead:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if ( ! is_product() ) {
            return $entity;
        }
        
        $product = wc_get_product( get_the_ID() );
        if ( ! $product->is_type( 'variable' ) ) {
            return $entity;
        }
        
        $variations = $product->get_available_variations();
    
        if ( ! empty( $variations ) ) {
            $offers = [];
            foreach ( $variations as $variation ) {
                $price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
    
                // $offers[] = [
                //     'price' => $variation['display_price'],
                // ];
    
                $offers[] = [
    				'@type'           => 'Offer',
    				'description'     => strip_tags( $variation['variation_description'] ),
    				'price'           => $variation['display_price'],
    				'priceCurrency'   => get_woocommerce_currency(),
    				'availability'    => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
    				'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
    				'url'             => $product->get_permalink(),
    			];
            }
        }
        
        $entity['offers'] = $offers;
        
        return $entity;
    } );

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

    Hello Jeremy

    Thank you very much or your help.
    I enabled it, and I’m waiting for Google crawl to see if my variations products are finally accepted > will keep you updated on this.

    To be more specific:
    I provide GG merchant center with the right price through an additional feed for Google Merchant Center. Using GG ids to match them with Google crawls, with the right url (with attribute parameter so Google understands there are variable products).
    The issue was that the price information collected by google crawls did not fit with the additional feed, as it seemingly collected only the lowest variation price > hence I needed to desactivate them.

    Unless I miss something, I don’t see how adding properties could fix it ?

    Hope that helps,

    hello again

    I can confirm it did not solve the issue, as the latest crawl still resulted in my 5 days variation to be rejected:

    10 mai 2022 10:03:56 CEST
    210.00EUR > feed price
    46.00EUR > website value

    Hello,

    I apologize, there seems to be an issue with the code I provided, I wasn’t able to remove the old price code. Please make use of this code instead:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if ( ! is_product() ) {
            return $entity;
        }
        
        $product = wc_get_product( get_the_ID() );
        if ( ! $product->is_type( 'variable' ) ) {
            return $entity;
        }
        
        $variations = $product->get_available_variations();
    
        if ( ! empty( $variations ) ) {
            $offers = [];
            foreach ( $variations as $variation ) {
                $price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
    
                $offers[] = [
    				'@type'           => 'Offer',
    				'description'     => strip_tags( $variation['variation_description'] ),
    				'price'           => $variation['display_price'],
    				'priceCurrency'   => get_woocommerce_currency(),
    				'availability'    => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
    				'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
    				'url'             => $product->get_permalink(),
    			];
            }
        }
        
        $entity['offers'] = $offers;
        
        return $entity;
    } );

    Let us know how that goes. Looking forward to helping you.

    hello Jeremy,

    So I added your amended code, but still my products are rejected due to prices discrepancies:
    For the 3rd variation after the last crawl:
    11 mai 2022 11:25:54 CEST
    132.00EUR
    46.00EUR

    > got rejected.

    Altough I’m not qualified to evaluate the codes, I understand where the probme lies & in case it could help, we can see the rich snippets results here :
    https://search.google.com/test/rich-results/result/r%2Fproduct?id=B1TzKPpISt9kkZUEwPQ_eg (for my 3 variation, url : https://lesjuspaf.bio/produit/les-cures/cure-detox/?attribute_nombre-de-jours=3)

    Prices are still detected – and I guess I either need to get rid of them or define the “url” field with the right variation url (with attribute parameter) so Google can match correctly. Right now it uses the lowest variation price for all variations.

    Many thanks for your help

    Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    thank your very much. However I did not share FTP login since it’s privatekey SFTP based, so not sure how to proceed. I think you don’t need em since I use snippet plug in to add codes and never go on a ftp level

    Many thanks for your help
    You will see that I tried different codes (TEST -) but none did work out.

    Hello,

    The Schema is being added correctly to your products and it shouldn’t be causing the issue. Please share a screenshot of the details of the error that you are getting in your GMC account. You can use a tool like https://imgbb.com/ to share the screenshots.

    Looking forward to helping you.

    Hi,

    Here it is : https://ibb.co/C8dTvpv

    thanks for your help

    Hello Jaideep

    Following up on this- does my screenshot helps ?

    Many thanks

    Hello,

    Everything seems fine on your site and our plugin is not adding the base price anywhere in the meta tags. I have enabled the filter to add the variation data to the Schema. Please make sure that the feed you are submitting to Google has the correct variation URL for the variations and not just the URL of the main product.

    Let us know how that goes. Looking forward to helping you.

    Jaideep,

    Thanks so much. It seemingly works perfectly now. For my understanding, where is located this filter ?

    best

    Hello,

    You can find the filter in the Code Snippets plugin with the name TEST – Modifier le display_price pour les variations // forum rankmath: fonctionne pas.

    Hope this helps. Let us know if you need any other assistance.

    Thanks.

    ok so this is one that I actually found – I thought you added a new one.

    thanks a lot for your help

Viewing 15 replies - 1 through 15 (of 18 total)

The ticket ‘Variable products rejected by Google Merchant Center due to price discrepancies’ is closed to new replies.