• Resolved Daniel P.

    (@danidub)


    Hello, I’ve seen your docs on offers.priceValidUntil tag, and as I understand now this value is added automatically. But I see this is applying on simple products but no on variable products.

    Is there a snippet to add this automatically to all variable products also? (Without adding the fields on each product).

    Also another question, variable products doesn’t have the offers.price parameter, under offer, I can see offers.lowPrice and offers.highPrice but not offers.price. Is there a way to add this also to variable products?

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @danidub,

    Thank you so much for getting in touch.

    Please refer to this filter code to add the required properties for the product 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; } );

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

Viewing 1 replies (of 1 total)
  • The topic ‘offers.priceValidUntil and offers.price is missing in variable product’ is closed to new replies.