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 ).
This commit is contained in:
Leon Rowland 2013-06-03 14:18:48 +02:00
parent cde4947acf
commit f238fe7066
1 changed files with 4 additions and 1 deletions

View File

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