diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index 124863785c0..bf5e4699abf 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -249,9 +249,11 @@ class WC_Product_Variable extends WC_Product { $price_hash = array( false ); } - foreach ( $wp_filter as $key => $val ) { - if ( in_array( $key, array( 'woocommerce_variation_prices_price', 'woocommerce_variation_prices_regular_price', 'woocommerce_variation_prices_sale_price' ) ) ) { - $price_hash[ $key ] = $val; + $filter_names = array( 'woocommerce_variation_prices_price', 'woocommerce_variation_prices_regular_price', 'woocommerce_variation_prices_sale_price' ); + + foreach ( $filter_names as $filter_name ) { + if ( ! empty( $wp_filter[ $filter_name ] ) ) { + $price_hash[ $filter_name ] = $wp_filter[ $filter_name ]; } }