Fix fatal error problems by no longer adding false to the list of orders
By adding this prevention, it also stops fatal errors (calling method on non-object) from happening down the line when working with the orders list that is always assumed to be a proper order object. Example error this prevents: ``` Fatal error: Uncaught Error: Call to a member function get_items() on bool in /wp-content/plugins/woocommerce/includes/class-wc-order.php on line 1902 ```
This commit is contained in:
parent
ca4cc1d6f1
commit
ceb3a0d753
|
@ -906,7 +906,14 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
|
|||
$this->prime_order_item_caches_for_orders( $order_ids, $query_vars );
|
||||
|
||||
foreach ( $query->posts as $post ) {
|
||||
$orders[] = wc_get_order( $post );
|
||||
$order = wc_get_order( $post );
|
||||
|
||||
// If the order returns false, don't add it to the list.
|
||||
if ( false === $order ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$orders[] = $order;
|
||||
}
|
||||
|
||||
return $orders;
|
||||
|
|
Loading…
Reference in New Issue