“Price” is missing on offers (Product Variation)

#465748
  • Resolved Ali Yorulmaz
    Rank Math free

    I checked search console and i have some missing schema lines.
    I guess woocommerce product schema(default) is do not have “price” line on offers on product variations.
    Main product has it.
    How can i fix this. Thank you.

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    The default Rank Math product schema does not add separate prices for variable products. However, you can add the code snippet below to add the offers schema for each product variation:

    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;
    } );

    And here’s a link on how to apply a filter on your site:
    https://rankmath.com/kb/filters-hooks-api-developer/#how-to-add-code-snippets-to-rank-math-php

    Once you have implemented the code snippet above, clear your website’s cache and check again.

    Let us know how this goes.

    Thank you.

    that seems like does not work because i am using my product schema (woocommerce product) instead of product. can u modify the code so it will work for woocommerce product snippet.

    Hello,

    The filter should be also applied to the WooCommerce Product schema.

    I’ve checked the product, and the missing price error is coming from a product schema being added by one of your plugins or active theme. Please refer to the result in the sensitive data section.

    Assuming you are using the latest version of all the plugins and the themes (please update if not yet), it would seem like a conflict with one of the plugins or the theme you are using.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Here is a video you can follow as well: https://www.youtube.com/watch?v=FcIWRhcUP2c

    Hope that helps.

    Thank you.

    Yes,
    It seems like it plugin schema conflict with “WooCommerce Google Product Feed” by Ademti Software Ltd.

    Exactly : [BETA] Include expanded schema markup on product pages.
    Note: Before enabling this option, please see this article about the status of the feature, and the potential consequences of using this pre-release feature.

    I deactivated it than it shows price on offers now.

    But, now rich results show 1 product with color options.
    Before i deactivate it it shows each product color as different product.

    Dont know which one wouldve better for indexing my products on google shopping. I need product cause rankmath does not have google product category selection option.

    Can u suggest me a best way to do it ? Thank you.

    Hello,

    Since that seems like a beta feature we don’t recommend using it on production websites.

    As for the Schema markup, our developers have improved the way this is generated recently to cater to the Google Merchant guidelines and to grant users the ease of mind to know that the products would be valid with all the well-known feed generators available at the moment.

    So, we recommend disabling that feature for now so that the offers appear correctly and comply with Google guidelines.

    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 ‘“Price” is missing on offers (Product Variation)’ is closed to new replies.