Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::query()publicWC 1.0

Метод класса: OrdersTableDataStore{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->query( $query_vars );
$query_vars (обязательный)
-

Код OrdersTableDataStore::query() WC 7.3.0

public function query( $query_vars ) {
	if ( ! isset( $query_vars['paginate'] ) || ! $query_vars['paginate'] ) {
		$query_vars['no_found_rows'] = true;
	}

	if ( isset( $query_vars['anonymized'] ) ) {
		$query_vars['meta_query'] = $query_vars['meta_query'] ?? array(); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query

		if ( $query_vars['anonymized'] ) {
			$query_vars['meta_query'][] = array(
				'key'   => '_anonymized',
				'value' => 'yes',
			);
		} else {
			$query_vars['meta_query'][] = array(
				'key'     => '_anonymized',
				'compare' => 'NOT EXISTS',
			);
		}
	}

	try {
		$query = new OrdersTableQuery( $query_vars );
	} catch ( \Exception $e ) {
		$query = (object) array(
			'orders'        => array(),
			'found_orders'  => 0,
			'max_num_pages' => 0,
		);
	}

	if ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) {
		$orders = $query->orders;
	} else {
		$orders = WC()->order_factory->get_orders( $query->orders );
	}

	if ( isset( $query_vars['paginate'] ) && $query_vars['paginate'] ) {
		return (object) array(
			'orders'        => $orders,
			'total'         => $query->found_orders,
			'max_num_pages' => $query->max_num_pages,
		);
	}

	return $orders;
}