priceValidUntil missing

  • Hi,

    i can not setup the priceValidUntil on variable product.

    Have found this fix for product feed, but i use the schema from rank math:

    // priceValidUntil
    
    function func_woocommerce_structured_data_product_offer( $markup, $product ) {
    
    	if ( empty( $markup[ 'priceValidUntil' ] ) ) {
    		$markup[ 'priceValidUntil' ] = '2050-01-01';
    	}		
    	return $markup;
    
    }
    
    add_filter( 'woocommerce_structured_data_product_offer', 'func_woocommerce_structured_data_product_offer', 10, 2 );

    which hook in rank math or woocommerce addon can i use for it? Thanks!

    • This topic was modified 3 days, 23 hours ago by  Martin.
    • This topic was modified 3 days, 23 hours ago by  Martin.
Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can use the following code to achieve the same in Rank Math:

    
    /**
     * Filter to modify Rank Math product schema data
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	$entity['offers']['priceValidUntil'] = '2050-01-01';
    	
    	return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.