diff --git a/includes/api/class-wc-api-customers.php b/includes/api/class-wc-api-customers.php index 174bba63b84..4fa7867d8e2 100644 --- a/includes/api/class-wc-api-customers.php +++ b/includes/api/class-wc-api-customers.php @@ -66,10 +66,11 @@ class WC_API_Customers extends WC_API_Resource { array( array( $this, 'get_customers_count' ), WC_API_SERVER::READABLE ), ); - # GET/PUT /customers/ + # GET/PUT/DELETE /customers/ $routes[ $this->base . '/(?P\d+)' ] = array( array( array( $this, 'get_customer' ), WC_API_SERVER::READABLE ), array( array( $this, 'edit_customer' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_customer' ), WC_API_SERVER::DELETABLE ), ); # GET /customers/ @@ -404,16 +405,19 @@ class WC_API_Customers extends WC_API_Resource { /** * Delete a customer * - * @TODO enable along with PUT/POST in 2.2 + * @since 2.2 * @param int $id the customer ID * @return array */ public function delete_customer( $id ) { + // Validate the customer ID. $id = $this->validate_request( $id, 'customer', 'delete' ); - if ( ! is_wp_error( $id ) ) - return $id; + // Return the validate error. + if ( is_wp_error( $id ) ) { + return new WP_Error( $id->get_error_code(), $id->get_error_message(), $id->get_error_data() ); + } return $this->delete( $id, 'customer' ); }