Automattic\WooCommerce\Internal\Admin\Schedulers
CustomersScheduler::get_items
Get the customer IDs and total count that need to be synced.
Method of the class: CustomersScheduler{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$result = CustomersScheduler::get_items( $limit, $page, $days, $skip_existing );
- $limit(int)
- Number of records to retrieve.
Default: 10 - $page(int)
- Page number.
Default: 1 - $days(int|true|false)
- Number of days prior to current date to limit search results.
Default: false - $skip_existing(true|false)
- Skip already imported customers.
Default: false
CustomersScheduler::get_items() CustomersScheduler::get items code WC 10.3.5
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(),
);
}