Automattic\WooCommerce\Internal\Admin\Schedulers

CustomersScheduler::get_items()public staticWC 1.0

Get the customer IDs and total count that need to be synced.

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

Хуки из метода

Возвращает

null. Ничего (null).

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

$result = CustomersScheduler::get_items( $limit, $page, $days, $skip_existing );
$limit(int)
Number of records to retrieve.
По умолчанию: 10
$page(int)
Page number.
По умолчанию: 1
$days(int|true|false)
Number of days prior to current date to limit search results.
По умолчанию: false
$skip_existing(true|false)
Skip already imported customers.
По умолчанию: false

Код CustomersScheduler::get_items() WC 8.7.0

public static function get_items( $limit = 10, $page = 1, $days = false, $skip_existing = false ) {
	$customer_roles = apply_filters( 'woocommerce_analytics_import_customer_roles', array( 'customer' ) );
	$query_args     = array(
		'fields'   => 'ID',
		'orderby'  => 'ID',
		'order'    => 'ASC',
		'number'   => $limit,
		'paged'    => $page,
		'role__in' => $customer_roles,
	);

	if ( is_int( $days ) ) {
		$query_args['date_query'] = array(
			'after' => gmdate( 'Y-m-d 00:00:00', time() - ( DAY_IN_SECONDS * $days ) ),
		);
	}

	if ( $skip_existing ) {
		add_action( 'pre_user_query', array( __CLASS__, 'exclude_existing_customers_from_query' ) );
	}

	$customer_query = new \WP_User_Query( $query_args );

	remove_action( 'pre_user_query', array( __CLASS__, 'exclude_existing_customers_from_query' ) );

	return (object) array(
		'total' => $customer_query->get_total(),
		'ids'   => $customer_query->get_results(),
	);
}