-
Hello guys!
im working on a function that changes the price if a product is connected to the page, but even if i hardcode ‘2.00’ for the price it doesn’t change the value of this specific meta data tag:
<meta property=”product:price:amount” content=”%price%”>It does show up in the Schema data which is great. Do u guys know what i do wrong?
add_filter( 'rank_math/snippet/rich_snippet_product_entity', 'strl_product_meta' );
function strl_product_meta( $entity ) {if ( empty( $entity['offers'] ) ) {
return $entity;
}$post_id = get_the_ID();
if ( empty( $post_id ) ) {
return;
}
$regular_price = 2; // strl_price_regular_callback( $post_id );
$sale_price = 1.50; // strl_price_regular_callback( $post_id );if ( empty( $regular_price ) && empty( $sale_price ) ) {
return;
}
$entity['offers']['price'] = ! empty( $sale_price ) ? $sale_price : $regular_price;
$entity['offers']['priceCurrency'] = 'EUR';return $entity;
}
The ticket ‘Snippet not working’ is closed to new replies.