WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Admin\API\Reports\Customers

DataStore::get_data() public WC 1.0

Returns the report data based on parameters supplied by the user.

{} Это метод класса: DataStore{}

Хуков нет.

Возвращает

stdClass/WP_Error. Data.

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

$DataStore = new DataStore();
$DataStore->get_data( $query_args );
$query_args(массив) (обязательный)
Query parameters.

Код DataStore::get_data() WC 4.7.0

<?php
public function get_data( $query_args ) {
	global $wpdb;

	$customers_table_name   = self::get_db_table_name();
	$order_stats_table_name = $wpdb->prefix . 'wc_order_stats';

	// These defaults are only partially applied when used via REST API, as that has its own defaults.
	$defaults   = array(
		'per_page'     => get_option( 'posts_per_page' ),
		'page'         => 1,
		'order'        => 'DESC',
		'orderby'      => 'date_registered',
		'order_before' => TimeInterval::default_before(),
		'order_after'  => TimeInterval::default_after(),
		'fields'       => '*',
	);
	$query_args = wp_parse_args( $query_args, $defaults );
	$this->normalize_timezones( $query_args, $defaults );

	/*
	 * We need to get the cache key here because
	 * parent::update_intervals_sql_params() modifies $query_args.
	 */
	$cache_key = $this->get_cache_key( $query_args );
	$data      = $this->get_cached_data( $cache_key );

	if ( false === $data ) {
		$this->initialize_queries();

		$data = (object) array(
			'data'    => array(),
			'total'   => 0,
			'pages'   => 0,
			'page_no' => 0,
		);

		$selections       = $this->selected_columns( $query_args );
		$sql_query_params = $this->add_sql_query_params( $query_args );
		$count_query      = "SELECT COUNT(*) FROM (
				{$this->subquery->get_query_statement()}
			) as tt
			";
		$db_records_count = (int) $wpdb->get_var(
			$count_query // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
		);

		$params      = $this->get_limit_params( $query_args );
		$total_pages = (int) ceil( $db_records_count / $params['per_page'] );
		if ( $query_args['page'] < 1 || $query_args['page'] > $total_pages ) {
			return $data;
		}

		$this->subquery->clear_sql_clause( 'select' );
		$this->subquery->add_sql_clause( 'select', $selections );
		$this->subquery->add_sql_clause( 'order_by', $this->get_sql_clause( 'order_by' ) );
		$this->subquery->add_sql_clause( 'limit', $this->get_sql_clause( 'limit' ) );

		$customer_data = $wpdb->get_results(
			$this->subquery->get_query_statement(), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
			ARRAY_A
		);

		if ( null === $customer_data ) {
			return $data;
		}

		$customer_data = array_map( array( $this, 'cast_numbers' ), $customer_data );
		$data          = (object) array(
			'data'    => $customer_data,
			'total'   => $db_records_count,
			'pages'   => $total_pages,
			'page_no' => (int) $query_args['page'],
		);

		$this->set_cached_data( $cache_key, $data );
	}

	return $data;
}