get_product in product factory should return passed in object if its a product already
Fixes #6726
This commit is contained in:
parent
9e53b3fb33
commit
a076c5a69d
|
@ -27,12 +27,15 @@ class WC_Product_Factory {
|
||||||
$the_product = $post;
|
$the_product = $post;
|
||||||
} elseif ( is_numeric( $the_product ) ) {
|
} elseif ( is_numeric( $the_product ) ) {
|
||||||
$the_product = get_post( $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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_object ( $the_product ) ) {
|
if ( is_object( $the_product ) ) {
|
||||||
$product_id = absint( $the_product->ID );
|
$product_id = absint( $the_product->ID );
|
||||||
$post_type = $the_product->post_type;
|
$post_type = $the_product->post_type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue