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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / rest-api / Controllers / Version2 / class-wc-rest-customers-v2-controller.php
woocommerce / includes / rest-api / Controllers / Version2 Last commit date
class-wc-rest-coupons-v2-controller.php 2 months ago class-wc-rest-customer-downloads-v2-controller.php 5 years ago class-wc-rest-customers-v2-controller.php 2 months ago class-wc-rest-network-orders-v2-controller.php 1 year ago class-wc-rest-order-notes-v2-controller.php 5 years ago class-wc-rest-order-refunds-v2-controller.php 2 months ago class-wc-rest-orders-v2-controller.php 1 month ago class-wc-rest-payment-gateways-v2-controller.php 11 months ago class-wc-rest-product-attribute-terms-v2-controller.php 5 years ago class-wc-rest-product-attributes-v2-controller.php 5 years ago class-wc-rest-product-brands-v2-controller.php 1 year ago class-wc-rest-product-categories-v2-controller.php 3 months ago class-wc-rest-product-reviews-v2-controller.php 4 years ago class-wc-rest-product-shipping-classes-v2-controller.php 5 years ago class-wc-rest-product-tags-v2-controller.php 5 years ago class-wc-rest-product-variations-v2-controller.php 2 months ago class-wc-rest-products-v2-controller.php 2 months ago class-wc-rest-report-sales-v2-controller.php 5 years ago class-wc-rest-report-top-sellers-v2-controller.php 5 years ago class-wc-rest-reports-v2-controller.php 5 years ago class-wc-rest-setting-options-v2-controller.php 2 months ago class-wc-rest-settings-v2-controller.php 5 years ago class-wc-rest-shipping-methods-v2-controller.php 1 year ago class-wc-rest-shipping-zone-locations-v2-controller.php 1 year ago class-wc-rest-shipping-zone-methods-v2-controller.php 1 year ago class-wc-rest-shipping-zones-v2-controller.php 1 month ago class-wc-rest-system-status-tools-v2-controller.php 1 month ago class-wc-rest-system-status-v2-controller.php 1 month ago class-wc-rest-tax-classes-v2-controller.php 1 year ago class-wc-rest-taxes-v2-controller.php 5 years ago class-wc-rest-webhook-deliveries-v2-controller.php 5 years ago class-wc-rest-webhooks-v2-controller.php 1 year ago
class-wc-rest-customers-v2-controller.php
396 lines
1 <?php
2 /**
3 * REST API Customers controller
4 *
5 * Handles requests to the /customers endpoint.
6 *
7 * @package WooCommerce\RestApi
8 * @since 2.6.0
9 */
10
11 use Automattic\WooCommerce\Utilities\MetaDataUtil;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * REST API Customers controller class.
17 *
18 * @package WooCommerce\RestApi
19 * @extends WC_REST_Customers_V1_Controller
20 */
21 class WC_REST_Customers_V2_Controller extends WC_REST_Customers_V1_Controller {
22
23 /**
24 * Endpoint namespace.
25 *
26 * @var string
27 */
28 protected $namespace = 'wc/v2';
29
30 /**
31 * Get formatted item data.
32 *
33 * @since 3.0.0
34 * @param WC_Data $object WC_Data instance.
35 * @return array
36 */
37 protected function get_formatted_item_data( $object ) {
38 $formatted_data = $this->get_formatted_item_data_core( $object );
39 $formatted_data['orders_count'] = $object->get_order_count();
40 $formatted_data['total_spent'] = $object->get_total_spent();
41 return $formatted_data;
42 }
43
44 /**
45 * Get formatted item data, not including orders count nor total spent.
46 * This method is needed because v3 API doesn't return those two fields.
47 *
48 * @internal This method could disappear or have its name or signature changed in future releases.
49 *
50 * @param WC_Data $object WC_Data instance.
51 * @return array
52 */
53 protected function get_formatted_item_data_core( $object ) {
54 $data = $object->get_data();
55 $format_date = array( 'date_created', 'date_modified' );
56
57 // Format date values.
58 foreach ( $format_date as $key ) {
59 // Date created is stored UTC, date modified is stored WP local time.
60 $datetime = 'date_created' === $key && is_subclass_of( $data[ $key ], 'DateTime' ) ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[ $key ]->getTimestamp() ) ) : $data[ $key ];
61 $data[ $key ] = wc_rest_prepare_date_response( $datetime, false );
62 $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
63 }
64
65 $formatted_data = array(
66 'id' => $object->get_id(),
67 'date_created' => $data['date_created'],
68 'date_created_gmt' => $data['date_created_gmt'],
69 'date_modified' => $data['date_modified'],
70 'date_modified_gmt' => $data['date_modified_gmt'],
71 'email' => $data['email'],
72 'first_name' => $data['first_name'],
73 'last_name' => $data['last_name'],
74 'role' => $data['role'],
75 'username' => $data['username'],
76 'billing' => $data['billing'],
77 'shipping' => $data['shipping'],
78 'is_paying_customer' => $data['is_paying_customer'],
79 'avatar_url' => $object->get_avatar_url(),
80 );
81
82 if ( wc_current_user_has_role( 'administrator' ) ) {
83 $formatted_data['meta_data'] = array_values(
84 array_filter(
85 $data['meta_data'],
86 function ( $meta ) {
87 return ! is_protected_meta( $meta->key, 'user' );
88 }
89 )
90 );
91 }
92
93 return $formatted_data;
94 }
95
96 /**
97 * Prepare a single customer output for response.
98 *
99 * @param WP_User $user_data User object.
100 * @param WP_REST_Request $request Request object.
101 * @return WP_REST_Response $response Response data.
102 */
103 public function prepare_item_for_response( $user_data, $request ) {
104 $customer = new WC_Customer( $user_data->ID );
105 $data = $this->get_formatted_item_data( $customer );
106 $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
107 $data = $this->add_additional_fields_to_object( $data, $request );
108 $data = $this->filter_response_by_context( $data, $context );
109 $response = rest_ensure_response( $data );
110 $response->add_links( $this->prepare_links( $user_data ) );
111
112 //phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment
113 /**
114 * Filter customer data returned from the REST API.
115 *
116 * @param WP_REST_Response $response The response object.
117 * @param WP_User $user_data User object used to create response.
118 * @param WP_REST_Request $request Request object.
119 */
120 return apply_filters( 'woocommerce_rest_prepare_customer', $response, $user_data, $request );
121 //phpcs:enable WooCommerce.Commenting.CommentHooks.MissingSinceComment
122 }
123
124 /**
125 * Update customer meta fields.
126 *
127 * @param WC_Customer $customer Customer data.
128 * @param WP_REST_Request $request Request data.
129 */
130 protected function update_customer_meta_fields( $customer, $request ) {
131 parent::update_customer_meta_fields( $customer, $request );
132
133 // Meta data.
134 if ( isset( $request['meta_data'] ) ) {
135 $meta_data = array_filter(
136 MetaDataUtil::normalize( $request['meta_data'] ),
137 fn( $meta ) => ! is_protected_meta( $meta['key'], 'user' )
138 );
139 MetaDataUtil::update( $meta_data, $customer );
140 }
141 }
142
143 /**
144 * Get the Customer's schema, conforming to JSON Schema.
145 *
146 * @return array
147 */
148 public function get_item_schema() {
149 $schema = array(
150 '$schema' => 'http://json-schema.org/draft-04/schema#',
151 'title' => 'customer',
152 'type' => 'object',
153 'properties' => array(
154 'id' => array(
155 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
156 'type' => 'integer',
157 'context' => array( 'view', 'edit' ),
158 'readonly' => true,
159 ),
160 'date_created' => array(
161 'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce' ),
162 'type' => 'date-time',
163 'context' => array( 'view', 'edit' ),
164 'readonly' => true,
165 ),
166 'date_created_gmt' => array(
167 'description' => __( 'The date the customer was created, as GMT.', 'woocommerce' ),
168 'type' => 'date-time',
169 'context' => array( 'view', 'edit' ),
170 'readonly' => true,
171 ),
172 'date_modified' => array(
173 'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce' ),
174 'type' => 'date-time',
175 'context' => array( 'view', 'edit' ),
176 'readonly' => true,
177 ),
178 'date_modified_gmt' => array(
179 'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ),
180 'type' => 'date-time',
181 'context' => array( 'view', 'edit' ),
182 'readonly' => true,
183 ),
184 'email' => array(
185 'description' => __( 'The email address for the customer.', 'woocommerce' ),
186 'type' => 'string',
187 'format' => 'email',
188 'context' => array( 'view', 'edit' ),
189 ),
190 'first_name' => array(
191 'description' => __( 'Customer first name.', 'woocommerce' ),
192 'type' => 'string',
193 'context' => array( 'view', 'edit' ),
194 'arg_options' => array(
195 'sanitize_callback' => 'sanitize_text_field',
196 ),
197 ),
198 'last_name' => array(
199 'description' => __( 'Customer last name.', 'woocommerce' ),
200 'type' => 'string',
201 'context' => array( 'view', 'edit' ),
202 'arg_options' => array(
203 'sanitize_callback' => 'sanitize_text_field',
204 ),
205 ),
206 'role' => array(
207 'description' => __( 'Customer role.', 'woocommerce' ),
208 'type' => 'string',
209 'context' => array( 'view', 'edit' ),
210 'readonly' => true,
211 ),
212 'username' => array(
213 'description' => __( 'Customer login name.', 'woocommerce' ),
214 'type' => 'string',
215 'context' => array( 'view', 'edit' ),
216 'arg_options' => array(
217 'sanitize_callback' => 'sanitize_user',
218 ),
219 ),
220 'password' => array(
221 'description' => __( 'Customer password.', 'woocommerce' ),
222 'type' => 'string',
223 'context' => array( 'edit' ),
224 ),
225 'billing' => array(
226 'description' => __( 'List of billing address data.', 'woocommerce' ),
227 'type' => 'object',
228 'context' => array( 'view', 'edit' ),
229 'properties' => array(
230 'first_name' => array(
231 'description' => __( 'First name.', 'woocommerce' ),
232 'type' => 'string',
233 'context' => array( 'view', 'edit' ),
234 ),
235 'last_name' => array(
236 'description' => __( 'Last name.', 'woocommerce' ),
237 'type' => 'string',
238 'context' => array( 'view', 'edit' ),
239 ),
240 'company' => array(
241 'description' => __( 'Company name.', 'woocommerce' ),
242 'type' => 'string',
243 'context' => array( 'view', 'edit' ),
244 ),
245 'address_1' => array(
246 'description' => __( 'Address line 1', 'woocommerce' ),
247 'type' => 'string',
248 'context' => array( 'view', 'edit' ),
249 ),
250 'address_2' => array(
251 'description' => __( 'Address line 2', 'woocommerce' ),
252 'type' => 'string',
253 'context' => array( 'view', 'edit' ),
254 ),
255 'city' => array(
256 'description' => __( 'City name.', 'woocommerce' ),
257 'type' => 'string',
258 'context' => array( 'view', 'edit' ),
259 ),
260 'state' => array(
261 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
262 'type' => 'string',
263 'context' => array( 'view', 'edit' ),
264 ),
265 'postcode' => array(
266 'description' => __( 'Postal code.', 'woocommerce' ),
267 'type' => 'string',
268 'context' => array( 'view', 'edit' ),
269 ),
270 'country' => array(
271 'description' => __( 'ISO code of the country.', 'woocommerce' ),
272 'type' => 'string',
273 'context' => array( 'view', 'edit' ),
274 ),
275 'email' => array(
276 'description' => __( 'Email address.', 'woocommerce' ),
277 'type' => 'string',
278 'format' => 'email',
279 'context' => array( 'view', 'edit' ),
280 ),
281 'phone' => array(
282 'description' => __( 'Phone number.', 'woocommerce' ),
283 'type' => 'string',
284 'context' => array( 'view', 'edit' ),
285 ),
286 ),
287 ),
288 'shipping' => array(
289 'description' => __( 'List of shipping address data.', 'woocommerce' ),
290 'type' => 'object',
291 'context' => array( 'view', 'edit' ),
292 'properties' => array(
293 'first_name' => array(
294 'description' => __( 'First name.', 'woocommerce' ),
295 'type' => 'string',
296 'context' => array( 'view', 'edit' ),
297 ),
298 'last_name' => array(
299 'description' => __( 'Last name.', 'woocommerce' ),
300 'type' => 'string',
301 'context' => array( 'view', 'edit' ),
302 ),
303 'company' => array(
304 'description' => __( 'Company name.', 'woocommerce' ),
305 'type' => 'string',
306 'context' => array( 'view', 'edit' ),
307 ),
308 'address_1' => array(
309 'description' => __( 'Address line 1', 'woocommerce' ),
310 'type' => 'string',
311 'context' => array( 'view', 'edit' ),
312 ),
313 'address_2' => array(
314 'description' => __( 'Address line 2', 'woocommerce' ),
315 'type' => 'string',
316 'context' => array( 'view', 'edit' ),
317 ),
318 'city' => array(
319 'description' => __( 'City name.', 'woocommerce' ),
320 'type' => 'string',
321 'context' => array( 'view', 'edit' ),
322 ),
323 'state' => array(
324 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
325 'type' => 'string',
326 'context' => array( 'view', 'edit' ),
327 ),
328 'postcode' => array(
329 'description' => __( 'Postal code.', 'woocommerce' ),
330 'type' => 'string',
331 'context' => array( 'view', 'edit' ),
332 ),
333 'country' => array(
334 'description' => __( 'ISO code of the country.', 'woocommerce' ),
335 'type' => 'string',
336 'context' => array( 'view', 'edit' ),
337 ),
338 ),
339 ),
340 'is_paying_customer' => array(
341 'description' => __( 'Is the customer a paying customer?', 'woocommerce' ),
342 'type' => 'bool',
343 'context' => array( 'view', 'edit' ),
344 'readonly' => true,
345 ),
346 'orders_count' => array(
347 'description' => __( 'Quantity of orders made by the customer.', 'woocommerce' ),
348 'type' => 'integer',
349 'context' => array( 'view', 'edit' ),
350 'readonly' => true,
351 ),
352 'total_spent' => array(
353 'description' => __( 'Total amount spent.', 'woocommerce' ),
354 'type' => 'string',
355 'context' => array( 'view', 'edit' ),
356 'readonly' => true,
357 ),
358 'avatar_url' => array(
359 'description' => __( 'Avatar URL.', 'woocommerce' ),
360 'type' => 'string',
361 'context' => array( 'view', 'edit' ),
362 'readonly' => true,
363 ),
364 'meta_data' => array(
365 'description' => __( 'Meta data.', 'woocommerce' ),
366 'type' => 'array',
367 'context' => array( 'view', 'edit' ),
368 'items' => array(
369 'type' => 'object',
370 'properties' => array(
371 'id' => array(
372 'description' => __( 'Meta ID.', 'woocommerce' ),
373 'type' => 'integer',
374 'context' => array( 'view', 'edit' ),
375 'readonly' => true,
376 ),
377 'key' => array(
378 'description' => __( 'Meta key.', 'woocommerce' ),
379 'type' => 'string',
380 'context' => array( 'view', 'edit' ),
381 ),
382 'value' => array(
383 'description' => __( 'Meta value.', 'woocommerce' ),
384 'type' => 'mixed',
385 'context' => array( 'view', 'edit' ),
386 ),
387 ),
388 ),
389 ),
390 ),
391 );
392
393 return $this->add_additional_fields_schema( $schema );
394 }
395 }
396