Product Variation Schema Not Available For Google Shopping Campaign

#79330
  • Resolved Tanveer
    Rank Math free
    Content AI Starter

    Product Schema shows a range of pricing for variable products that have different pricing. Google Merchant Center wants a price for each variable, else it will accept the lowest price of all variations. So, we need the markup to show each variable with its individual GTIN/MPN, pricing, and SKU as opposed to the ‘AggregateOffer’. I know your work is as per Google guidelines but here we need some more help.

    While going through many tickets on the same topic, I’ve already noted the points from your side. But please understand, this is the issue with everyone who is using rankmath schema, woocommerce variable products, and google shopping. And there are obviously a lot of people like me who feel highly comfortable with rankmath and the other two, and would not like to add any additional plugin for schema, as you’ve suggested in one ticket.

    If this issue isn’t getting resolved in your upcoming update, please provide us with some code snippet filter (like you’ve provided us for using same brand value for all products and many others) to just copy-paste. I’ve searched using ‘schema price variation’ in your knowledge base, and I can already see around 22 tickets with same problem, and can’t find any solution to it.

    Thanks.

    • This topic was modified 3 years, 7 months ago by Tanveer.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    The following code was provided to provide the entities for each of the variations. You can use it as it is or change to only assign price for your variations:

    
    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' ) ) {
    		$entity['gtin13'] = get_post_meta( get_the_ID(), 'hwp_var_gtin', true );
    		return $entity;
    	}
    
    	$variations = $product->get_available_variations();
    	if ( ! empty( $variations ) ) {
    		$entity['offers'] = [];
    		foreach ( $variations as $variation ) {
    			$price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
    			$entity['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',
    				'itemCondition'   => 'NewCondition',
    				'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
    				'url'             => $product->get_permalink(),
    				'gtin13'          => get_post_meta($variation['variation_id'],'hwp_var_gtin', true ),
    			];
    		}
    	}
    
    	return $entity;
    } );
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    Tanveer
    Rank Math free
    Content AI Starter

    Hi. Thanks a lot for the help. I’ve implemented this but it works. But I can’t find variation SKU in it. Can you please add a variation SKU and variation MPN in it? I’ve tried changing ‘gtn13’ to ‘mpn’ in this code but it isn’t working.

    I’m using SKU as MPN using the following code provided by you.

    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘mpn’] = $entity[‘sku’];
    return $entity;

    Hello,

    You can try adding the following to the previous filter to fix the issue with SKU

    
    'sku' => get_post_meta($variation['variation_id'],'variable_sku', true ),
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    Tanveer
    Rank Math free
    Content AI Starter

    Thanks a lot. 🙂

    Alberto
    Rank Math business

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Product Variation Schema Not Available For Google Shopping Campaign’ is closed to new replies.