Merge pull request #14113 from woocommerce/fix/product-object-checks
Fix/product object checks
This commit is contained in:
commit
ef6895fd56
|
@ -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' :
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue