Skip to content

Instantly share code, notes, and snippets.

@billerickson billerickson/functions.php Secret
Created Jul 5, 2019

Embed
What would you like to do?
<?php
/**
* Add price to product review schema
* @see https://www.billerickson.net
*
* @param array $data
* @param object $context
* @return array
*/
function be_price_review_schema( $data, $context ) {
$price = get_post_meta( $context->id, 'be_price', true );
if( !empty( $price ) ) {
$data['itemReviewed']['offers'] = array(
'@type' => 'Offer',
'availability' => 'http://schema.org/InStock',
'price' => $price,
'priceCurrency' => 'USD'
);
}
return $data;
}
add_filter( 'be_review_schema_data', 'be_price_review_schema', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.