Woocommerce Variation Product SKU not showing in Schema

#779660
  • Resolved Anonymous
    Rank Math free

    Greetings, I am having trouble getting the variation sku to show in the product schema. My products have variations and each one has a unique sku as per your guide but the schema output does not show the sku.

    We are in an industry where the sku for some of our products is something that people will use in searches so this is an important choice as to the SEO plugin we use.

    Here is one of the products that I have been testing https://thelightingcentre.co.nz/product/apollo-wall-sconce-with-white-glass/

    Thanks,
    Benjamin

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

    I apologize for the inconvenience you are facing with the WooCommerce Variation Product SKU not showing in the product schema. To ensure that the SKU is included in the product schema, please follow these steps:

    1. Edit Your Product: Head over to your product and click on Edit.
      Edit Product

    2. Navigate to the Schema Settings for the Product: Click on the Schema tab and then click on Schema Generator.
      Click on Schema Generator

    3. Navigate to the Schema Builder: Find the WooCommerce Product Schema from the list and click on Use to open the Schema Builder.
      Use WooCommerce Product Schema

    4. Save the Schema Type: In the Schema Builder, click on Save for this Post.
      Click on Save for this Post

    By following these steps, you can configure the WooCommerce Product Schema to include the SKU information in the product schema. If you encounter any further issues or need additional assistance, please feel free to reach out.

    Thank you for bringing this concern to our attention.

    Best regards.

    Sources:
    How to Use Product Schema for WooCommerce Products » Rank Math
    Google Search Console Missing Field Warning » Rank Math
    How to Use Product Schema for WooCommerce Products » Rank Math
    How to Customize Schema Markup for WooCommerce Products » Rank Math
    Resolving Rank Math Schema Markup Related Issues

    Anonymous
    Rank Math free

    Hi, I have followed these instructions, the schema was already set to woocommerce products, but I deleted this and set it to woocommerce product and it has not fixed the issue.

    Hello,

    Thank you for your patience.

    In this case, please refer to this filter code to ensure that the SKU is included in each offers property in your schema:

    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(),
    					'sku'             => $variation['sku'],
    				];
    			}
    	}
    	
    	$entity['offers'] = $offers;
    	
    	return $entity;
    } );

    If you’re not sure how to add this code, you can follow this guide:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Once done, clear your website’s cache and check again the applied schema to your product.

    Let us know how this goes.

    Anonymous
    Rank Math free

    Thanks very much this looks like it has fixed it to me, I will just wait to see if this results in more visibility in time. I appreciate your prompt and comprehensive help.

    Cheers

    Hello,

    Sure, do let us know how that goes. We are glad that we could address your concern.

    If you 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)

You must be logged in to reply to this ticket.