Product variant pricing mismatch with Google Merchant Center

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

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    The code we provided in the previous ticket was provided because you said that the prices were not changing but you still wanted to have offers for each variation.

    Now it seems that the requirements changed and if the price is now changing you don’t need any filter because our plugin automatically outputs the multiple prices when there’s variation in the price as we explained in the previous ticket.

    In case you don’t see this happening on your website please share a couple of links after disabling the filter applied previously so we can check the situation.

    ​​​​​​​Hope this helps solve your issues.

    Don’t hesitate to get in touch if you have any other questions.

    Kevin
    Rank Math free

    Hello again Miguel,

    Turning off the filter you’ve implemented in my website will bring back the previous problem I had with google merchant.

    I’d like to keep the solution you provided on my previous ticket (https://support.rankmath.com/ticket/variable-product-availability-schema/)
    It fixed my “availability” mismatch with google merchant.

    Here’s the snippet you’ve implemented in my website that permanently fixed my “availability” mismatch:

    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',
    				'sku'			  => $variation['sku'],
    				'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
    				'url'             => $product->get_permalink(),
    			];
    		}
    	}
    
    	$entity['offers'] = $offers;
    
    	return $entity;
    } );

    Since now google merchant is giving a price mismatch error, I’d like to know how to fix it without disabling the filter you’ve provided me that fixed my “availability” mismatch.

    Thank you

    Hello,

    That filter already includes all the information for the displayed price of each variation and we tested on our end on a default installation and it’s outputting the correct price for each one.

    Having said that, we always recommend that if you are going to change the prices for each variation you let the plugin generate the Schema automatically because it will also generate the aggregate offers and apply the low and high price values that would indicate to Google the price range.

    As mentioned before, the filter was created as per your requirements and with the information that the price was the same. If the price is changing the best way is to let the plugin control the aggregate offers prices.

    Don’t hesitate to get in touch if you have any other questions.

    Kevin
    Rank Math free

    If I turn off the snippet you’ve previously made for me google will throw my previous “availability mismatch” error again.

    Example: blue, red, green variant. If blue is the only variant out of stock, google insist blue should be “in stock”.

    I’m aware that the snippet you’ve made for me shows correct variant price, but I’m not sure why google thinks the price should be the lowest price among all variations.

    So, how do we fix the schema so both of the variant “availability” and “price” mismatch can be fixed together?

    Thank you Miguel

    Hello,

    What Google sees about the price is what you have outputted on your page and the mismatch probably indicates the same, that it was found via a page crawl.

    You’ll need to check the WooCommerce settings to make sure that the price you are inserting doesn’t include taxes or anything that could alter the price.

    If that doesn’t help you might need to make some refinements to the filter, especially in the way the price is retrieved for each variation.

    We also recommend that you read through this guide to learn more about the way Google tries to identify the price and the guidelines that you need to set for your prices on the website: https://support.google.com/merchants/answer/6324371

    Don’t hesitate to get in touch if you have any other questions.

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

The ticket ‘Product variant pricing mismatch with Google Merchant Center’ is closed to new replies.