diff --git a/includes/admin/reports/class-wc-report-stock.php b/includes/admin/reports/class-wc-report-stock.php index 9778538a02e..46bcc9f7f51 100644 --- a/includes/admin/reports/class-wc-report-stock.php +++ b/includes/admin/reports/class-wc-report-stock.php @@ -80,6 +80,10 @@ class WC_Report_Stock extends WP_List_Table { $product = wc_get_product( $item->id ); } + if ( ! $product ) { + return; + } + switch ( $column_name ) { case 'product' : diff --git a/includes/api/legacy/v1/class-wc-api-products.php b/includes/api/legacy/v1/class-wc-api-products.php index afaf0e58cae..c8cc9813fe4 100644 --- a/includes/api/legacy/v1/class-wc-api-products.php +++ b/includes/api/legacy/v1/class-wc-api-products.php @@ -345,7 +345,7 @@ class WC_API_Products extends WC_API_Resource { foreach ( $product->get_children() as $child_id ) { $variation = wc_get_product( $child_id ); - if ( ! $variation->exists() ) { + if ( ! $variation || ! $variation->exists() ) { continue; } diff --git a/includes/api/legacy/v2/class-wc-api-products.php b/includes/api/legacy/v2/class-wc-api-products.php index 2c565e815a0..ca27e67f376 100644 --- a/includes/api/legacy/v2/class-wc-api-products.php +++ b/includes/api/legacy/v2/class-wc-api-products.php @@ -767,7 +767,7 @@ class WC_API_Products extends WC_API_Resource { $variation = wc_get_product( $child_id ); - if ( ! $variation->exists() ) { + if ( ! $variation || ! $variation->exists() ) { continue; } diff --git a/includes/api/legacy/v3/class-wc-api-products.php b/includes/api/legacy/v3/class-wc-api-products.php index a2bbcf6bbbd..cc27943e094 100644 --- a/includes/api/legacy/v3/class-wc-api-products.php +++ b/includes/api/legacy/v3/class-wc-api-products.php @@ -1225,7 +1225,7 @@ class WC_API_Products extends WC_API_Resource { foreach ( $product->get_children() as $child_id ) { $variation = wc_get_product( $child_id ); - if ( ! $variation->exists() ) { + if ( ! $variation || ! $variation->exists() ) { continue; } diff --git a/includes/api/v1/class-wc-rest-products-controller.php b/includes/api/v1/class-wc-rest-products-controller.php index 41d73585568..26d907fd6c3 100644 --- a/includes/api/v1/class-wc-rest-products-controller.php +++ b/includes/api/v1/class-wc-rest-products-controller.php @@ -540,7 +540,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { foreach ( $product->get_children() as $child_id ) { $variation = wc_get_product( $child_id ); - if ( ! $variation->exists() ) { + if ( ! $variation || ! $variation->exists() ) { continue; } diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index ad51eba0a8f..742e2061461 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -244,7 +244,7 @@ class WC_Product_Variable extends WC_Product { $variation = wc_get_product( $child_id ); // Hide out of stock variations if 'Hide out of stock items from the catalog' is checked - if ( ! $variation->exists() || ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $variation->is_in_stock() ) ) { + if ( ! $variation || ! $variation->exists() || ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $variation->is_in_stock() ) ) { continue; }