From f238fe7066840af1c8961ebeb738f540ce7aad4d Mon Sep 17 00:00:00 2001 From: Leon Rowland Date: Mon, 3 Jun 2013 14:18:48 +0200 Subject: [PATCH] Fix for WooCommerce2 + where get_product cant return an instance of WC_Product and the property to hold the ID is in lowercase. This causes the property to not correct set. When the property isn't correct set it breaks the magic method __get ( which in turn stops the correct return values of calls to SKU or any other meta. This includes updating stock ). --- classes/abstracts/abstract-wc-product.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/abstracts/abstract-wc-product.php b/classes/abstracts/abstract-wc-product.php index 5fb856cf4d4..1b199e221ff 100644 --- a/classes/abstracts/abstract-wc-product.php +++ b/classes/abstracts/abstract-wc-product.php @@ -35,9 +35,12 @@ class WC_Product { $product = get_product( $product ); } - if ( is_object( $product ) ) { + if ( $product instanceof WP_Post ) { $this->id = absint( $product->ID ); $this->post = $product; + } elseif ( $product instanceof WC_Product ) { + $this->id = absint( $product->id ); + $this->post = $product; } else { $this->id = absint( $product ); $this->post = get_post( $this->id );