Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::get_order_data_for_ids
Retrieve raw order data for multiple IDs.
Method of the class: OrdersTableDataStore{}
No Hooks.
Returns
\stdClass[]. DB Order objects or error.
Usage
// protected - for code of main (parent) or child class $result = $this->get_order_data_for_ids( $ids ): array;
- $ids(int[]) (required)
- List of order IDs.
OrdersTableDataStore::get_order_data_for_ids() OrdersTableDataStore::get order data for ids code WC 10.8.1
protected function get_order_data_for_ids( array $ids ): array {
if ( empty( $ids ) ) {
return array();
}
$using_datastore_cache = OrderUtil::custom_orders_table_datastore_cache_enabled();
$order_data = array();
if ( $using_datastore_cache ) {
$order_data = $this->get_order_data_for_ids_from_cache( $ids );
$ids = array_diff( $ids, array_keys( $order_data ) );
}
if ( count( $ids ) > 0 ) {
$db_order_data = $this->get_order_data_for_ids_from_db( $ids );
$order_data = $db_order_data + $order_data;
if ( count( $db_order_data ) > 0 && $using_datastore_cache ) {
$this->set_order_data_in_cache( $db_order_data );
}
}
$order_data = array_filter( $order_data );
$meta_data = $this->data_store_meta->get_meta_data_for_object_ids( array_keys( $order_data ) );
foreach ( $meta_data as $order_id => $order_meta ) {
$order_data[ $order_id ]->meta_data = $order_meta;
}
return $order_data;
}