Merge pull request #6538 from krautnerds/rest-api-all-customer-fix

REST API 2.0 Add possibility to get all customers
This commit is contained in:
Mike Jolley 2014-10-16 15:54:00 +01:00
commit 9fb4e1cee4
1 changed files with 7 additions and 5 deletions

View File

@ -526,10 +526,12 @@ class WC_API_Customers extends WC_API_Resource {
// limit number of users returned // limit number of users returned
if ( ! empty( $args['limit'] ) ) { if ( ! empty( $args['limit'] ) ) {
if ( $args['limit'] == -1 ) {
$query_args['number'] = absint( $args['limit'] ); unset( $query_args['number'] );
} else {
$users_per_page = absint( $args['limit'] ); $query_args['number'] = absint( $args['limit'] );
$users_per_page = absint( $args['limit'] );
}
} }
// page // page
@ -569,7 +571,7 @@ class WC_API_Customers extends WC_API_Resource {
$query = new WP_User_Query( $query_args ); $query = new WP_User_Query( $query_args );
// helper members for pagination headers // helper members for pagination headers
$query->total_pages = ceil( $query->get_total() / $users_per_page ); $query->total_pages = ( $args['limit'] == -1 ) ? 1 : ceil( $query->get_total() / $users_per_page );
$query->page = $page; $query->page = $page;
return $query; return $query;