From a076c5a69daf73c9a5c61b7614abe95b8e68a3b9 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 11 Nov 2014 16:24:22 +0000 Subject: [PATCH] get_product in product factory should return passed in object if its a product already Fixes #6726 --- includes/class-wc-product-factory.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-product-factory.php b/includes/class-wc-product-factory.php index 91e17144944..b58b6bfb4b8 100644 --- a/includes/class-wc-product-factory.php +++ b/includes/class-wc-product-factory.php @@ -27,12 +27,15 @@ class WC_Product_Factory { $the_product = $post; } elseif ( is_numeric( $the_product ) ) { $the_product = get_post( $the_product ); + } elseif ( $the_product instanceof WC_Product ) { + return $the_product; } - if ( ! $the_product ) + if ( ! $the_product ) { return false; + } - if ( is_object ( $the_product ) ) { + if ( is_object( $the_product ) ) { $product_id = absint( $the_product->ID ); $post_type = $the_product->post_type; }