Check for required fields or bail

This commit is contained in:
Mike Jolley 2019-03-05 11:44:26 +00:00
parent bf11dbf76f
commit 545cbbb79c
1 changed files with 5 additions and 0 deletions

View File

@ -312,6 +312,11 @@ class WC_Structured_Data {
} }
} }
// Check we have required data.
if ( empty( $markup['aggregateRating'] ) && empty( $markup['offers'] ) && empty( $markup['review'] ) ) {
return;
}
$this->set_data( apply_filters( 'woocommerce_structured_data_product', $markup, $product ) ); $this->set_data( apply_filters( 'woocommerce_structured_data_product', $markup, $product ) );
} }