From 545cbbb79c9440a172a6e2dc9be125fdef34ef04 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 5 Mar 2019 11:44:26 +0000 Subject: [PATCH] Check for required fields or bail --- includes/class-wc-structured-data.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-wc-structured-data.php b/includes/class-wc-structured-data.php index f4e57e7ab4c..e22e8c63d32 100644 --- a/includes/class-wc-structured-data.php +++ b/includes/class-wc-structured-data.php @@ -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 ) ); }