Prevent notices in factory
This commit is contained in:
parent
8a1d7707ac
commit
f6b78be21c
|
@ -30,27 +30,27 @@ class WC_Order_Factory {
|
|||
$the_order = get_post( $the_order );
|
||||
}
|
||||
|
||||
if ( ! $the_order )
|
||||
if ( ! is_object( $the_order ) ) {
|
||||
return false;
|
||||
|
||||
if ( is_object ( $the_order ) ) {
|
||||
$order_id = absint( $the_order->ID );
|
||||
$post_type = $the_order->post_type;
|
||||
}
|
||||
|
||||
if ( 'shop_order' == $post_type ) {
|
||||
$classname = 'WC_Order';
|
||||
$order_id = absint( $the_order->ID );
|
||||
$post_type = $the_order->post_type;
|
||||
|
||||
if ( 'shop_order' === $post_type ) {
|
||||
$classname = 'WC_Order';
|
||||
$order_type = 'simple';
|
||||
} else {
|
||||
$classname = false;
|
||||
$classname = false;
|
||||
$order_type = false;
|
||||
}
|
||||
|
||||
// Filter classname so that the class can be overridden if extended.
|
||||
$classname = apply_filters( 'woocommerce_order_class', $classname, $order_type, $post_type, $order_id );
|
||||
|
||||
if ( ! class_exists( $classname ) )
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
$classname = 'WC_Order';
|
||||
}
|
||||
|
||||
return new $classname( $the_order, $args );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue