Merge pull request #14113 from woocommerce/fix/product-object-checks

Fix/product object checks
This commit is contained in:
Claudio Sanches 2017-04-07 12:31:28 -03:00 committed by GitHub
commit ef6895fd56
6 changed files with 9 additions and 5 deletions

View File

@ -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' :

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}