restrict customer import to customer role with filter

This commit is contained in:
Ron Rennick 2019-05-13 13:47:16 -03:00
parent 38c40430ef
commit 28b10f2eb6
1 changed files with 11 additions and 7 deletions

View File

@ -589,12 +589,14 @@ class WC_Admin_Reports_Sync {
*/ */
public static function customer_lookup_import_batch_init( $days, $skip_existing ) { public static function customer_lookup_import_batch_init( $days, $skip_existing ) {
$batch_size = self::get_batch_size( self::CUSTOMERS_IMPORT_BATCH_ACTION ); $batch_size = self::get_batch_size( self::CUSTOMERS_IMPORT_BATCH_ACTION );
$customer_roles = apply_filters( 'woocommerce_admin_import_customer_roles', array( 'customer' ) );
$customer_query = self::get_user_ids_for_batch( $customer_query = self::get_user_ids_for_batch(
$days, $days,
$skip_existing, $skip_existing,
array( array(
'fields' => 'ID', 'fields' => 'ID',
'number' => 1, 'number' => 1,
'role__in' => $customer_roles,
) )
); );
$total_customers = $customer_query->get_total(); $total_customers = $customer_query->get_total();
@ -618,15 +620,17 @@ class WC_Admin_Reports_Sync {
*/ */
public static function customer_lookup_import_batch( $batch_number, $days, $skip_existing ) { public static function customer_lookup_import_batch( $batch_number, $days, $skip_existing ) {
$batch_size = self::get_batch_size( self::CUSTOMERS_IMPORT_BATCH_ACTION ); $batch_size = self::get_batch_size( self::CUSTOMERS_IMPORT_BATCH_ACTION );
$customer_roles = apply_filters( 'woocommerce_admin_import_customer_roles', array( 'customer' ) );
$customer_query = self::get_user_ids_for_batch( $customer_query = self::get_user_ids_for_batch(
$days, $days,
$skip_existing, $skip_existing,
array( array(
'fields' => 'ID', 'fields' => 'ID',
'orderby' => 'ID', 'orderby' => 'ID',
'order' => 'ASC', 'order' => 'ASC',
'number' => $batch_size, 'number' => $batch_size,
'paged' => $batch_number, 'paged' => $batch_number,
'role__in' => $customer_roles,
) )
); );