Try catch and false for products
This commit is contained in:
parent
89e628f3d5
commit
3b9934a2b1
|
@ -45,7 +45,11 @@ class WC_Order_Factory {
|
|||
return false;
|
||||
}
|
||||
|
||||
return new $classname( $order_id );
|
||||
try {
|
||||
return new $classname( $order_id );
|
||||
} catch ( Exception $e ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ class WC_Product_Factory {
|
|||
*
|
||||
* @param mixed $product_id (default: false)
|
||||
* @param array $deprecated
|
||||
* @return WC_Product|null Product object or null if the product cannot be loaded.
|
||||
* @return WC_Product|bool Product object or null if the product cannot be loaded.
|
||||
*/
|
||||
public function get_product( $product_id = false, $deprecated = array() ) {
|
||||
$product_id = $this->get_product_id( $product_id );
|
||||
|
@ -38,7 +38,7 @@ class WC_Product_Factory {
|
|||
$classname = apply_filters( 'woocommerce_product_class', $classname, $product_type, $post_type, $product_id );
|
||||
|
||||
if ( ! $classname ) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
|
@ -48,7 +48,7 @@ class WC_Product_Factory {
|
|||
try {
|
||||
return new $classname( $product_id );
|
||||
} catch ( Exception $e ) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue