From 770d81091d6d17a3c939cf26f7e592bd5f016e4a Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Tue, 24 Jun 2014 14:56:33 -0300 Subject: [PATCH] fixed a error when get the thumbnail by API Fixed the error: PHP Notice: Trying to get property of non-object in wp-includes/post-template.php on line 29 --- includes/abstracts/abstract-wc-product.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 7c5b702c4bb..9c0b159c97f 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -106,9 +106,10 @@ class WC_Product { if ( ! isset( $this->product_image_gallery ) ) { // Backwards compat $attachment_ids = get_posts( 'post_parent=' . $this->id . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image&fields=ids&meta_key=_woocommerce_exclude_image&meta_value=0' ); - $attachment_ids = array_diff( $attachment_ids, array( get_post_thumbnail_id() ) ); + $attachment_ids = array_diff( $attachment_ids, array( get_post_thumbnail_id( $this->id ) ) ); $this->product_image_gallery = implode( ',', $attachment_ids ); } + return apply_filters( 'woocommerce_product_gallery_attachment_ids', array_filter( (array) explode( ',', $this->product_image_gallery ) ), $this ); } @@ -165,7 +166,7 @@ class WC_Product { /** * Set stock level of the product. * - * Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues). + * Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues). * We cannot rely on the original loaded value in case another order was made since then. * * @param int $amount (default: null) @@ -207,7 +208,7 @@ class WC_Product { } /** - * Reduce stock level of the product. + * Reduce stock level of the product. * * @param int $amount (default: 1) Amount to reduce by. * @return int new stock level @@ -223,7 +224,7 @@ class WC_Product { * @return int new stock level */ public function increase_stock( $amount = 1 ) { - return $this->set_stock( $amount, 'add' ); + return $this->set_stock( $amount, 'add' ); } /**