Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::prime_caches_for_orderspublicWC 1.0

Prime caches for a collection of orders. Reduces N+1 queries when iterating over order results.

Method of the class: OrdersTableDataStore{}

No Hooks.

Returns

null. Nothing (null).

Usage

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->prime_caches_for_orders( $order_ids, $query_vars ): void;
$order_ids(array) (required)
List of order IDs to prime caches for.
$query_vars(array) (required)
Original query arguments.

OrdersTableDataStore::prime_caches_for_orders() code WC 10.7.0

public function prime_caches_for_orders( array $order_ids, array $query_vars ): void {
	$this->prime_order_item_caches_for_orders( $order_ids, $query_vars );

	// The following priming methods only apply to shop_order queries.
	$order_type = $query_vars['type'] ?? $query_vars['post_type'] ?? '';
	$order_type = is_array( $order_type ) ? $order_type : array( $order_type );
	if ( ! in_array( 'shop_order', $order_type, true ) ) {
		return;
	}

	$this->prime_refund_caches_for_orders( $order_ids, $query_vars );
	$this->prime_refund_total_caches_for_orders( $order_ids, $query_vars );
	$this->prime_needs_processing_transients( $order_ids, $query_vars );
}