Completed
Push — master ( ee9494...a1e9b4 )
by Mike
45:32
created
src/Controllers/Version4/Products.php 1 patch
Spacing   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Controllers\Version4;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 /**
15 15
  * REST API Products controller class.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * Initialize product actions.
42 42
 	 */
43 43
 	public function __construct() {
44
-		add_action( "woocommerce_rest_insert_{$this->post_type}_object", array( $this, 'clear_transients' ) );
44
+		add_action("woocommerce_rest_insert_{$this->post_type}_object", array($this, 'clear_transients'));
45 45
 	}
46 46
 
47 47
 	/**
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 			array(
55 55
 				array(
56 56
 					'methods'             => \WP_REST_Server::READABLE,
57
-					'callback'            => array( $this, 'get_items' ),
58
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
+					'callback'            => array($this, 'get_items'),
58
+					'permission_callback' => array($this, 'get_items_permissions_check'),
59 59
 					'args'                => $this->get_collection_params(),
60 60
 				),
61 61
 				array(
62 62
 					'methods'             => \WP_REST_Server::CREATABLE,
63
-					'callback'            => array( $this, 'create_item' ),
64
-					'permission_callback' => array( $this, 'create_item_permissions_check' ),
65
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ),
63
+					'callback'            => array($this, 'create_item'),
64
+					'permission_callback' => array($this, 'create_item_permissions_check'),
65
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
66 66
 				),
67
-				'schema' => array( $this, 'get_public_item_schema' ),
67
+				'schema' => array($this, 'get_public_item_schema'),
68 68
 			),
69 69
 			true
70 70
 		);
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 			array(
76 76
 				'args'   => array(
77 77
 					'id' => array(
78
-						'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
78
+						'description' => __('Unique identifier for the resource.', 'woocommerce'),
79 79
 						'type'        => 'integer',
80 80
 					),
81 81
 				),
82 82
 				array(
83 83
 					'methods'             => \WP_REST_Server::READABLE,
84
-					'callback'            => array( $this, 'get_item' ),
85
-					'permission_callback' => array( $this, 'get_item_permissions_check' ),
84
+					'callback'            => array($this, 'get_item'),
85
+					'permission_callback' => array($this, 'get_item_permissions_check'),
86 86
 					'args'                => array(
87 87
 						'context' => $this->get_context_param(
88 88
 							array(
@@ -93,23 +93,23 @@  discard block
 block discarded – undo
93 93
 				),
94 94
 				array(
95 95
 					'methods'             => \WP_REST_Server::EDITABLE,
96
-					'callback'            => array( $this, 'update_item' ),
97
-					'permission_callback' => array( $this, 'update_item_permissions_check' ),
98
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
96
+					'callback'            => array($this, 'update_item'),
97
+					'permission_callback' => array($this, 'update_item_permissions_check'),
98
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
99 99
 				),
100 100
 				array(
101 101
 					'methods'             => \WP_REST_Server::DELETABLE,
102
-					'callback'            => array( $this, 'delete_item' ),
103
-					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
102
+					'callback'            => array($this, 'delete_item'),
103
+					'permission_callback' => array($this, 'delete_item_permissions_check'),
104 104
 					'args'                => array(
105 105
 						'force' => array(
106 106
 							'default'     => false,
107
-							'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
107
+							'description' => __('Whether to bypass trash and force deletion.', 'woocommerce'),
108 108
 							'type'        => 'boolean',
109 109
 						),
110 110
 					),
111 111
 				),
112
-				'schema' => array( $this, 'get_public_item_schema' ),
112
+				'schema' => array($this, 'get_public_item_schema'),
113 113
 			),
114 114
 			true
115 115
 		);
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			array(
121 121
 				array(
122 122
 					'methods'             => \WP_REST_Server::EDITABLE,
123
-					'callback'            => array( $this, 'batch_items' ),
124
-					'permission_callback' => array( $this, 'batch_items_permissions_check' ),
125
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
123
+					'callback'            => array($this, 'batch_items'),
124
+					'permission_callback' => array($this, 'batch_items_permissions_check'),
125
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
126 126
 				),
127
-				'schema' => array( $this, 'get_public_batch_schema' ),
127
+				'schema' => array($this, 'get_public_batch_schema'),
128 128
 			),
129 129
 			true
130 130
 		);
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 	 * @since  3.0.0
139 139
 	 * @return \WC_Data
140 140
 	 */
141
-	protected function get_object( $id ) {
142
-		return wc_get_product( $id );
141
+	protected function get_object($id) {
142
+		return wc_get_product($id);
143 143
 	}
144 144
 
145 145
 	/**
@@ -151,24 +151,24 @@  discard block
 block discarded – undo
151 151
 	 * @since  3.0.0
152 152
 	 * @return \WP_REST_Response
153 153
 	 */
154
-	public function prepare_object_for_response( $object, $request ) {
155
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
156
-		$data    = $this->get_product_data( $object, $context );
154
+	public function prepare_object_for_response($object, $request) {
155
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
156
+		$data    = $this->get_product_data($object, $context);
157 157
 
158 158
 		// Add variations to variable products.
159
-		if ( $object->is_type( 'variable' ) && $object->has_child() ) {
159
+		if ($object->is_type('variable') && $object->has_child()) {
160 160
 			$data['variations'] = $object->get_children();
161 161
 		}
162 162
 
163 163
 		// Add grouped products data.
164
-		if ( $object->is_type( 'grouped' ) && $object->has_child() ) {
164
+		if ($object->is_type('grouped') && $object->has_child()) {
165 165
 			$data['grouped_products'] = $object->get_children();
166 166
 		}
167 167
 
168
-		$data     = $this->add_additional_fields_to_object( $data, $request );
169
-		$data     = $this->filter_response_by_context( $data, $context );
170
-		$response = rest_ensure_response( $data );
171
-		$response->add_links( $this->prepare_links( $object, $request ) );
168
+		$data     = $this->add_additional_fields_to_object($data, $request);
169
+		$data     = $this->filter_response_by_context($data, $context);
170
+		$response = rest_ensure_response($data);
171
+		$response->add_links($this->prepare_links($object, $request));
172 172
 
173 173
 		/**
174 174
 		 * Filter the data for a response.
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		 * @param \WC_Data          $object   Object data.
181 181
 		 * @param \WP_REST_Request  $request  Request object.
182 182
 		 */
183
-		return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
183
+		return apply_filters("woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,28 +190,28 @@  discard block
 block discarded – undo
190 190
 	 * @param  bool             $creating If is creating a new object.
191 191
 	 * @return \WP_Error|\WC_Data
192 192
 	 */
193
-	protected function prepare_object_for_database( $request, $creating = false ) {
194
-		$id = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
193
+	protected function prepare_object_for_database($request, $creating = false) {
194
+		$id = isset($request['id']) ? absint($request['id']) : 0;
195 195
 
196 196
 		// Type is the most important part here because we need to be using the correct class and methods.
197
-		if ( isset( $request['type'] ) ) {
198
-			$classname = \WC_Product_Factory::get_classname_from_product_type( $request['type'] );
197
+		if (isset($request['type'])) {
198
+			$classname = \WC_Product_Factory::get_classname_from_product_type($request['type']);
199 199
 
200
-			if ( ! class_exists( $classname ) ) {
200
+			if ( ! class_exists($classname)) {
201 201
 				$classname = 'WC_Product_Simple';
202 202
 			}
203 203
 
204
-			$product = new $classname( $id );
205
-		} elseif ( isset( $request['id'] ) ) {
206
-			$product = wc_get_product( $id );
204
+			$product = new $classname($id);
205
+		} elseif (isset($request['id'])) {
206
+			$product = wc_get_product($id);
207 207
 		} else {
208 208
 			$product = new \WC_Product_Simple();
209 209
 		}
210 210
 
211
-		if ( 'variation' === $product->get_type() ) {
211
+		if ('variation' === $product->get_type()) {
212 212
 			return new \WP_Error(
213 213
 				"woocommerce_rest_invalid_{$this->post_type}_id",
214
-				__( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ),
214
+				__('To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce'),
215 215
 				array(
216 216
 					'status' => 404,
217 217
 				)
@@ -219,365 +219,365 @@  discard block
 block discarded – undo
219 219
 		}
220 220
 
221 221
 		// Post title.
222
-		if ( isset( $request['name'] ) ) {
223
-			$product->set_name( wp_filter_post_kses( $request['name'] ) );
222
+		if (isset($request['name'])) {
223
+			$product->set_name(wp_filter_post_kses($request['name']));
224 224
 		}
225 225
 
226 226
 		// Post content.
227
-		if ( isset( $request['description'] ) ) {
228
-			$product->set_description( wp_filter_post_kses( $request['description'] ) );
227
+		if (isset($request['description'])) {
228
+			$product->set_description(wp_filter_post_kses($request['description']));
229 229
 		}
230 230
 
231 231
 		// Post excerpt.
232
-		if ( isset( $request['short_description'] ) ) {
233
-			$product->set_short_description( wp_filter_post_kses( $request['short_description'] ) );
232
+		if (isset($request['short_description'])) {
233
+			$product->set_short_description(wp_filter_post_kses($request['short_description']));
234 234
 		}
235 235
 
236 236
 		// Post status.
237
-		if ( isset( $request['status'] ) ) {
238
-			$product->set_status( get_post_status_object( $request['status'] ) ? $request['status'] : 'draft' );
237
+		if (isset($request['status'])) {
238
+			$product->set_status(get_post_status_object($request['status']) ? $request['status'] : 'draft');
239 239
 		}
240 240
 
241 241
 		// Post slug.
242
-		if ( isset( $request['slug'] ) ) {
243
-			$product->set_slug( $request['slug'] );
242
+		if (isset($request['slug'])) {
243
+			$product->set_slug($request['slug']);
244 244
 		}
245 245
 
246 246
 		// Menu order.
247
-		if ( isset( $request['menu_order'] ) ) {
248
-			$product->set_menu_order( $request['menu_order'] );
247
+		if (isset($request['menu_order'])) {
248
+			$product->set_menu_order($request['menu_order']);
249 249
 		}
250 250
 
251 251
 		// Comment status.
252
-		if ( isset( $request['reviews_allowed'] ) ) {
253
-			$product->set_reviews_allowed( $request['reviews_allowed'] );
252
+		if (isset($request['reviews_allowed'])) {
253
+			$product->set_reviews_allowed($request['reviews_allowed']);
254 254
 		}
255 255
 
256 256
 		// Virtual.
257
-		if ( isset( $request['virtual'] ) ) {
258
-			$product->set_virtual( $request['virtual'] );
257
+		if (isset($request['virtual'])) {
258
+			$product->set_virtual($request['virtual']);
259 259
 		}
260 260
 
261 261
 		// Tax status.
262
-		if ( isset( $request['tax_status'] ) ) {
263
-			$product->set_tax_status( $request['tax_status'] );
262
+		if (isset($request['tax_status'])) {
263
+			$product->set_tax_status($request['tax_status']);
264 264
 		}
265 265
 
266 266
 		// Tax Class.
267
-		if ( isset( $request['tax_class'] ) ) {
268
-			$product->set_tax_class( $request['tax_class'] );
267
+		if (isset($request['tax_class'])) {
268
+			$product->set_tax_class($request['tax_class']);
269 269
 		}
270 270
 
271 271
 		// Catalog Visibility.
272
-		if ( isset( $request['catalog_visibility'] ) ) {
273
-			$product->set_catalog_visibility( $request['catalog_visibility'] );
272
+		if (isset($request['catalog_visibility'])) {
273
+			$product->set_catalog_visibility($request['catalog_visibility']);
274 274
 		}
275 275
 
276 276
 		// Purchase Note.
277
-		if ( isset( $request['purchase_note'] ) ) {
278
-			$product->set_purchase_note( wp_kses_post( wp_unslash( $request['purchase_note'] ) ) );
277
+		if (isset($request['purchase_note'])) {
278
+			$product->set_purchase_note(wp_kses_post(wp_unslash($request['purchase_note'])));
279 279
 		}
280 280
 
281 281
 		// Featured Product.
282
-		if ( isset( $request['featured'] ) ) {
283
-			$product->set_featured( $request['featured'] );
282
+		if (isset($request['featured'])) {
283
+			$product->set_featured($request['featured']);
284 284
 		}
285 285
 
286 286
 		// Shipping data.
287
-		$product = $this->save_product_shipping_data( $product, $request );
287
+		$product = $this->save_product_shipping_data($product, $request);
288 288
 
289 289
 		// SKU.
290
-		if ( isset( $request['sku'] ) ) {
291
-			$product->set_sku( wc_clean( $request['sku'] ) );
290
+		if (isset($request['sku'])) {
291
+			$product->set_sku(wc_clean($request['sku']));
292 292
 		}
293 293
 
294 294
 		// Attributes.
295
-		if ( isset( $request['attributes'] ) ) {
295
+		if (isset($request['attributes'])) {
296 296
 			$attributes = array();
297 297
 
298
-			foreach ( $request['attributes'] as $attribute ) {
298
+			foreach ($request['attributes'] as $attribute) {
299 299
 				$attribute_id   = 0;
300 300
 				$attribute_name = '';
301 301
 
302 302
 				// Check ID for global attributes or name for product attributes.
303
-				if ( ! empty( $attribute['id'] ) ) {
304
-					$attribute_id   = absint( $attribute['id'] );
305
-					$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
306
-				} elseif ( ! empty( $attribute['name'] ) ) {
307
-					$attribute_name = wc_clean( $attribute['name'] );
303
+				if ( ! empty($attribute['id'])) {
304
+					$attribute_id   = absint($attribute['id']);
305
+					$attribute_name = wc_attribute_taxonomy_name_by_id($attribute_id);
306
+				} elseif ( ! empty($attribute['name'])) {
307
+					$attribute_name = wc_clean($attribute['name']);
308 308
 				}
309 309
 
310
-				if ( ! $attribute_id && ! $attribute_name ) {
310
+				if ( ! $attribute_id && ! $attribute_name) {
311 311
 					continue;
312 312
 				}
313 313
 
314
-				if ( $attribute_id ) {
314
+				if ($attribute_id) {
315 315
 
316
-					if ( isset( $attribute['options'] ) ) {
316
+					if (isset($attribute['options'])) {
317 317
 						$options = $attribute['options'];
318 318
 
319
-						if ( ! is_array( $attribute['options'] ) ) {
319
+						if ( ! is_array($attribute['options'])) {
320 320
 							// Text based attributes - Posted values are term names.
321
-							$options = explode( WC_DELIMITER, $options );
321
+							$options = explode(WC_DELIMITER, $options);
322 322
 						}
323 323
 
324
-						$values = array_map( 'wc_sanitize_term_text_based', $options );
325
-						$values = array_filter( $values, 'strlen' );
324
+						$values = array_map('wc_sanitize_term_text_based', $options);
325
+						$values = array_filter($values, 'strlen');
326 326
 					} else {
327 327
 						$values = array();
328 328
 					}
329 329
 
330
-					if ( ! empty( $values ) ) {
330
+					if ( ! empty($values)) {
331 331
 						// Add attribute to array, but don't set values.
332 332
 						$attribute_object = new \WC_Product_Attribute();
333
-						$attribute_object->set_id( $attribute_id );
334
-						$attribute_object->set_name( $attribute_name );
335
-						$attribute_object->set_options( $values );
336
-						$attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' );
337
-						$attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 );
338
-						$attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 );
333
+						$attribute_object->set_id($attribute_id);
334
+						$attribute_object->set_name($attribute_name);
335
+						$attribute_object->set_options($values);
336
+						$attribute_object->set_position(isset($attribute['position']) ? (string) absint($attribute['position']) : '0');
337
+						$attribute_object->set_visible((isset($attribute['visible']) && $attribute['visible']) ? 1 : 0);
338
+						$attribute_object->set_variation((isset($attribute['variation']) && $attribute['variation']) ? 1 : 0);
339 339
 						$attributes[] = $attribute_object;
340 340
 					}
341
-				} elseif ( isset( $attribute['options'] ) ) {
341
+				} elseif (isset($attribute['options'])) {
342 342
 					// Custom attribute - Add attribute to array and set the values.
343
-					if ( is_array( $attribute['options'] ) ) {
343
+					if (is_array($attribute['options'])) {
344 344
 						$values = $attribute['options'];
345 345
 					} else {
346
-						$values = explode( WC_DELIMITER, $attribute['options'] );
346
+						$values = explode(WC_DELIMITER, $attribute['options']);
347 347
 					}
348 348
 					$attribute_object = new \WC_Product_Attribute();
349
-					$attribute_object->set_name( $attribute_name );
350
-					$attribute_object->set_options( $values );
351
-					$attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' );
352
-					$attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 );
353
-					$attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 );
349
+					$attribute_object->set_name($attribute_name);
350
+					$attribute_object->set_options($values);
351
+					$attribute_object->set_position(isset($attribute['position']) ? (string) absint($attribute['position']) : '0');
352
+					$attribute_object->set_visible((isset($attribute['visible']) && $attribute['visible']) ? 1 : 0);
353
+					$attribute_object->set_variation((isset($attribute['variation']) && $attribute['variation']) ? 1 : 0);
354 354
 					$attributes[] = $attribute_object;
355 355
 				}
356 356
 			}
357
-			$product->set_attributes( $attributes );
357
+			$product->set_attributes($attributes);
358 358
 		}
359 359
 
360 360
 		// Sales and prices.
361
-		if ( in_array( $product->get_type(), array( 'variable', 'grouped' ), true ) ) {
362
-			$product->set_regular_price( '' );
363
-			$product->set_sale_price( '' );
364
-			$product->set_date_on_sale_to( '' );
365
-			$product->set_date_on_sale_from( '' );
366
-			$product->set_price( '' );
361
+		if (in_array($product->get_type(), array('variable', 'grouped'), true)) {
362
+			$product->set_regular_price('');
363
+			$product->set_sale_price('');
364
+			$product->set_date_on_sale_to('');
365
+			$product->set_date_on_sale_from('');
366
+			$product->set_price('');
367 367
 		} else {
368 368
 			// Regular Price.
369
-			if ( isset( $request['regular_price'] ) ) {
370
-				$product->set_regular_price( $request['regular_price'] );
369
+			if (isset($request['regular_price'])) {
370
+				$product->set_regular_price($request['regular_price']);
371 371
 			}
372 372
 
373 373
 			// Sale Price.
374
-			if ( isset( $request['sale_price'] ) ) {
375
-				$product->set_sale_price( $request['sale_price'] );
374
+			if (isset($request['sale_price'])) {
375
+				$product->set_sale_price($request['sale_price']);
376 376
 			}
377 377
 
378
-			if ( isset( $request['date_on_sale_from'] ) ) {
379
-				$product->set_date_on_sale_from( $request['date_on_sale_from'] );
378
+			if (isset($request['date_on_sale_from'])) {
379
+				$product->set_date_on_sale_from($request['date_on_sale_from']);
380 380
 			}
381 381
 
382
-			if ( isset( $request['date_on_sale_from_gmt'] ) ) {
383
-				$product->set_date_on_sale_from( $request['date_on_sale_from_gmt'] ? strtotime( $request['date_on_sale_from_gmt'] ) : null );
382
+			if (isset($request['date_on_sale_from_gmt'])) {
383
+				$product->set_date_on_sale_from($request['date_on_sale_from_gmt'] ? strtotime($request['date_on_sale_from_gmt']) : null);
384 384
 			}
385 385
 
386
-			if ( isset( $request['date_on_sale_to'] ) ) {
387
-				$product->set_date_on_sale_to( $request['date_on_sale_to'] );
386
+			if (isset($request['date_on_sale_to'])) {
387
+				$product->set_date_on_sale_to($request['date_on_sale_to']);
388 388
 			}
389 389
 
390
-			if ( isset( $request['date_on_sale_to_gmt'] ) ) {
391
-				$product->set_date_on_sale_to( $request['date_on_sale_to_gmt'] ? strtotime( $request['date_on_sale_to_gmt'] ) : null );
390
+			if (isset($request['date_on_sale_to_gmt'])) {
391
+				$product->set_date_on_sale_to($request['date_on_sale_to_gmt'] ? strtotime($request['date_on_sale_to_gmt']) : null);
392 392
 			}
393 393
 		}
394 394
 
395 395
 		// Product parent ID.
396
-		if ( isset( $request['parent_id'] ) ) {
397
-			$product->set_parent_id( $request['parent_id'] );
396
+		if (isset($request['parent_id'])) {
397
+			$product->set_parent_id($request['parent_id']);
398 398
 		}
399 399
 
400 400
 		// Sold individually.
401
-		if ( isset( $request['sold_individually'] ) ) {
402
-			$product->set_sold_individually( $request['sold_individually'] );
401
+		if (isset($request['sold_individually'])) {
402
+			$product->set_sold_individually($request['sold_individually']);
403 403
 		}
404 404
 
405 405
 		// Stock status; stock_status has priority over in_stock.
406
-		if ( isset( $request['stock_status'] ) ) {
406
+		if (isset($request['stock_status'])) {
407 407
 			$stock_status = $request['stock_status'];
408 408
 		} else {
409 409
 			$stock_status = $product->get_stock_status();
410 410
 		}
411 411
 
412 412
 		// Stock data.
413
-		if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
413
+		if ('yes' === get_option('woocommerce_manage_stock')) {
414 414
 			// Manage stock.
415
-			if ( isset( $request['manage_stock'] ) ) {
416
-				$product->set_manage_stock( $request['manage_stock'] );
415
+			if (isset($request['manage_stock'])) {
416
+				$product->set_manage_stock($request['manage_stock']);
417 417
 			}
418 418
 
419 419
 			// Backorders.
420
-			if ( isset( $request['backorders'] ) ) {
421
-				$product->set_backorders( $request['backorders'] );
420
+			if (isset($request['backorders'])) {
421
+				$product->set_backorders($request['backorders']);
422 422
 			}
423 423
 
424
-			if ( $product->is_type( 'grouped' ) ) {
425
-				$product->set_manage_stock( 'no' );
426
-				$product->set_backorders( 'no' );
427
-				$product->set_stock_quantity( '' );
428
-				$product->set_stock_status( $stock_status );
429
-			} elseif ( $product->is_type( 'external' ) ) {
430
-				$product->set_manage_stock( 'no' );
431
-				$product->set_backorders( 'no' );
432
-				$product->set_stock_quantity( '' );
433
-				$product->set_stock_status( 'instock' );
434
-			} elseif ( $product->get_manage_stock() ) {
424
+			if ($product->is_type('grouped')) {
425
+				$product->set_manage_stock('no');
426
+				$product->set_backorders('no');
427
+				$product->set_stock_quantity('');
428
+				$product->set_stock_status($stock_status);
429
+			} elseif ($product->is_type('external')) {
430
+				$product->set_manage_stock('no');
431
+				$product->set_backorders('no');
432
+				$product->set_stock_quantity('');
433
+				$product->set_stock_status('instock');
434
+			} elseif ($product->get_manage_stock()) {
435 435
 				// Stock status is always determined by children so sync later.
436
-				if ( ! $product->is_type( 'variable' ) ) {
437
-					$product->set_stock_status( $stock_status );
436
+				if ( ! $product->is_type('variable')) {
437
+					$product->set_stock_status($stock_status);
438 438
 				}
439 439
 
440 440
 				// Stock quantity.
441
-				if ( isset( $request['stock_quantity'] ) ) {
442
-					$product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) );
443
-				} elseif ( isset( $request['inventory_delta'] ) ) {
444
-					$stock_quantity  = wc_stock_amount( $product->get_stock_quantity() );
445
-					$stock_quantity += wc_stock_amount( $request['inventory_delta'] );
446
-					$product->set_stock_quantity( wc_stock_amount( $stock_quantity ) );
441
+				if (isset($request['stock_quantity'])) {
442
+					$product->set_stock_quantity(wc_stock_amount($request['stock_quantity']));
443
+				} elseif (isset($request['inventory_delta'])) {
444
+					$stock_quantity  = wc_stock_amount($product->get_stock_quantity());
445
+					$stock_quantity += wc_stock_amount($request['inventory_delta']);
446
+					$product->set_stock_quantity(wc_stock_amount($stock_quantity));
447 447
 				}
448 448
 			} else {
449 449
 				// Don't manage stock.
450
-				$product->set_manage_stock( 'no' );
451
-				$product->set_stock_quantity( '' );
452
-				$product->set_stock_status( $stock_status );
450
+				$product->set_manage_stock('no');
451
+				$product->set_stock_quantity('');
452
+				$product->set_stock_status($stock_status);
453 453
 			}
454
-		} elseif ( ! $product->is_type( 'variable' ) ) {
455
-			$product->set_stock_status( $stock_status );
454
+		} elseif ( ! $product->is_type('variable')) {
455
+			$product->set_stock_status($stock_status);
456 456
 		}
457 457
 
458 458
 		// Upsells.
459
-		if ( isset( $request['upsell_ids'] ) ) {
459
+		if (isset($request['upsell_ids'])) {
460 460
 			$upsells = array();
461 461
 			$ids     = $request['upsell_ids'];
462 462
 
463
-			if ( ! empty( $ids ) ) {
464
-				foreach ( $ids as $id ) {
465
-					if ( $id && $id > 0 ) {
463
+			if ( ! empty($ids)) {
464
+				foreach ($ids as $id) {
465
+					if ($id && $id > 0) {
466 466
 						$upsells[] = $id;
467 467
 					}
468 468
 				}
469 469
 			}
470 470
 
471
-			$product->set_upsell_ids( $upsells );
471
+			$product->set_upsell_ids($upsells);
472 472
 		}
473 473
 
474 474
 		// Cross sells.
475
-		if ( isset( $request['cross_sell_ids'] ) ) {
475
+		if (isset($request['cross_sell_ids'])) {
476 476
 			$crosssells = array();
477 477
 			$ids        = $request['cross_sell_ids'];
478 478
 
479
-			if ( ! empty( $ids ) ) {
480
-				foreach ( $ids as $id ) {
481
-					if ( $id && $id > 0 ) {
479
+			if ( ! empty($ids)) {
480
+				foreach ($ids as $id) {
481
+					if ($id && $id > 0) {
482 482
 						$crosssells[] = $id;
483 483
 					}
484 484
 				}
485 485
 			}
486 486
 
487
-			$product->set_cross_sell_ids( $crosssells );
487
+			$product->set_cross_sell_ids($crosssells);
488 488
 		}
489 489
 
490 490
 		// Product categories.
491
-		if ( isset( $request['categories'] ) && is_array( $request['categories'] ) ) {
492
-			$product = $this->save_taxonomy_terms( $product, $request['categories'] );
491
+		if (isset($request['categories']) && is_array($request['categories'])) {
492
+			$product = $this->save_taxonomy_terms($product, $request['categories']);
493 493
 		}
494 494
 
495 495
 		// Product tags.
496
-		if ( isset( $request['tags'] ) && is_array( $request['tags'] ) ) {
497
-			$product = $this->save_taxonomy_terms( $product, $request['tags'], 'tag' );
496
+		if (isset($request['tags']) && is_array($request['tags'])) {
497
+			$product = $this->save_taxonomy_terms($product, $request['tags'], 'tag');
498 498
 		}
499 499
 
500 500
 		// Downloadable.
501
-		if ( isset( $request['downloadable'] ) ) {
502
-			$product->set_downloadable( $request['downloadable'] );
501
+		if (isset($request['downloadable'])) {
502
+			$product->set_downloadable($request['downloadable']);
503 503
 		}
504 504
 
505 505
 		// Downloadable options.
506
-		if ( $product->get_downloadable() ) {
506
+		if ($product->get_downloadable()) {
507 507
 
508 508
 			// Downloadable files.
509
-			if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) {
510
-				$product = $this->save_downloadable_files( $product, $request['downloads'] );
509
+			if (isset($request['downloads']) && is_array($request['downloads'])) {
510
+				$product = $this->save_downloadable_files($product, $request['downloads']);
511 511
 			}
512 512
 
513 513
 			// Download limit.
514
-			if ( isset( $request['download_limit'] ) ) {
515
-				$product->set_download_limit( $request['download_limit'] );
514
+			if (isset($request['download_limit'])) {
515
+				$product->set_download_limit($request['download_limit']);
516 516
 			}
517 517
 
518 518
 			// Download expiry.
519
-			if ( isset( $request['download_expiry'] ) ) {
520
-				$product->set_download_expiry( $request['download_expiry'] );
519
+			if (isset($request['download_expiry'])) {
520
+				$product->set_download_expiry($request['download_expiry']);
521 521
 			}
522 522
 		}
523 523
 
524 524
 		// Product url and button text for external products.
525
-		if ( $product->is_type( 'external' ) ) {
526
-			if ( isset( $request['external_url'] ) ) {
527
-				$product->set_product_url( $request['external_url'] );
525
+		if ($product->is_type('external')) {
526
+			if (isset($request['external_url'])) {
527
+				$product->set_product_url($request['external_url']);
528 528
 			}
529 529
 
530
-			if ( isset( $request['button_text'] ) ) {
531
-				$product->set_button_text( $request['button_text'] );
530
+			if (isset($request['button_text'])) {
531
+				$product->set_button_text($request['button_text']);
532 532
 			}
533 533
 		}
534 534
 
535 535
 		// Save default attributes for variable products.
536
-		if ( $product->is_type( 'variable' ) ) {
537
-			$product = $this->save_default_attributes( $product, $request );
536
+		if ($product->is_type('variable')) {
537
+			$product = $this->save_default_attributes($product, $request);
538 538
 		}
539 539
 
540 540
 		// Set children for a grouped product.
541
-		if ( $product->is_type( 'grouped' ) && isset( $request['grouped_products'] ) ) {
542
-			$product->set_children( $request['grouped_products'] );
541
+		if ($product->is_type('grouped') && isset($request['grouped_products'])) {
542
+			$product->set_children($request['grouped_products']);
543 543
 		}
544 544
 
545 545
 		// Check for featured/gallery images, upload it and set it.
546
-		if ( isset( $request['images'] ) ) {
547
-			$product = $this->set_product_images( $product, $request['images'] );
546
+		if (isset($request['images'])) {
547
+			$product = $this->set_product_images($product, $request['images']);
548 548
 		}
549 549
 
550 550
 		// Allow set meta_data.
551
-		if ( is_array( $request['meta_data'] ) ) {
552
-			foreach ( $request['meta_data'] as $meta ) {
553
-				$product->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
551
+		if (is_array($request['meta_data'])) {
552
+			foreach ($request['meta_data'] as $meta) {
553
+				$product->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : '');
554 554
 			}
555 555
 		}
556 556
 
557
-		if ( ! empty( $request['date_created'] ) ) {
558
-			$date = rest_parse_date( $request['date_created'] );
557
+		if ( ! empty($request['date_created'])) {
558
+			$date = rest_parse_date($request['date_created']);
559 559
 
560
-			if ( $date ) {
561
-				$product->set_date_created( $date );
560
+			if ($date) {
561
+				$product->set_date_created($date);
562 562
 			}
563 563
 		}
564 564
 
565
-		if ( ! empty( $request['date_created_gmt'] ) ) {
566
-			$date = rest_parse_date( $request['date_created_gmt'], true );
565
+		if ( ! empty($request['date_created_gmt'])) {
566
+			$date = rest_parse_date($request['date_created_gmt'], true);
567 567
 
568
-			if ( $date ) {
569
-				$product->set_date_created( $date );
568
+			if ($date) {
569
+				$product->set_date_created($date);
570 570
 			}
571 571
 		}
572 572
 
573
-		if ( ! empty( $request['search'] ) ) {
574
-			$args['search'] = trim( $request['search'] );
575
-			unset( $args['s'] );
573
+		if ( ! empty($request['search'])) {
574
+			$args['search'] = trim($request['search']);
575
+			unset($args['s']);
576 576
 		}
577 577
 
578
-		if ( ! empty( $request['low_in_stock'] ) ) {
578
+		if ( ! empty($request['low_in_stock'])) {
579 579
 			$args['low_in_stock'] = $request['low_in_stock'];
580
-			$args['post_type']    = array( 'product', 'product_variation' );
580
+			$args['post_type']    = array('product', 'product_variation');
581 581
 		}
582 582
 
583 583
 		/**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 		 * @param \WP_REST_Request $request  Request object.
591 591
 		 * @param bool            $creating If is creating a new object.
592 592
 		 */
593
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $product, $request, $creating );
593
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $product, $request, $creating);
594 594
 	}
595 595
 
596 596
 	/**
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
 	 * @param \WP_REST_Request $request Full details about the request.
600 600
 	 * @return \WP_Error\WP_REST_Response
601 601
 	 */
602
-	public function get_items( $request ) {
603
-		add_filter( 'posts_where', array( __CLASS__, 'add_wp_query_filter' ), 10, 2 );
604
-		add_filter( 'posts_join', array( __CLASS__, 'add_wp_query_join' ), 10, 2 );
605
-		add_filter( 'posts_groupby', array( __CLASS__, 'add_wp_query_group_by' ), 10, 2 );
606
-		$response = parent::get_items( $request );
607
-		remove_filter( 'posts_where', array( __CLASS__, 'add_wp_query_filter' ), 10 );
608
-		remove_filter( 'posts_join', array( __CLASS__, 'add_wp_query_join' ), 10 );
609
-		remove_filter( 'posts_groupby', array( __CLASS__, 'add_wp_query_group_by' ), 10 );
602
+	public function get_items($request) {
603
+		add_filter('posts_where', array(__CLASS__, 'add_wp_query_filter'), 10, 2);
604
+		add_filter('posts_join', array(__CLASS__, 'add_wp_query_join'), 10, 2);
605
+		add_filter('posts_groupby', array(__CLASS__, 'add_wp_query_group_by'), 10, 2);
606
+		$response = parent::get_items($request);
607
+		remove_filter('posts_where', array(__CLASS__, 'add_wp_query_filter'), 10);
608
+		remove_filter('posts_join', array(__CLASS__, 'add_wp_query_join'), 10);
609
+		remove_filter('posts_groupby', array(__CLASS__, 'add_wp_query_group_by'), 10);
610 610
 		return $response;
611 611
 	}
612 612
 
@@ -617,19 +617,19 @@  discard block
 block discarded – undo
617 617
 	 * @param object $wp_query \WP_Query object.
618 618
 	 * @return string
619 619
 	 */
620
-	public static function add_wp_query_filter( $where, $wp_query ) {
620
+	public static function add_wp_query_filter($where, $wp_query) {
621 621
 		global $wpdb;
622 622
 
623
-		$search = $wp_query->get( 'search' );
624
-		if ( $search ) {
625
-			$search = $wpdb->esc_like( $search );
623
+		$search = $wp_query->get('search');
624
+		if ($search) {
625
+			$search = $wpdb->esc_like($search);
626 626
 			$search = "'%" . $search . "%'";
627 627
 			$where .= " AND ({$wpdb->posts}.post_title LIKE {$search}";
628 628
 			$where .= wc_product_sku_enabled() ? ' OR ps_post_meta.meta_key = "_sku" AND ps_post_meta.meta_value LIKE ' . $search . ')' : ')';
629 629
 		}
630 630
 
631
-		if ( $wp_query->get( 'low_in_stock' ) ) {
632
-			$low_stock_amount = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
631
+		if ($wp_query->get('low_in_stock')) {
632
+			$low_stock_amount = absint(max(get_option('woocommerce_notify_low_stock_amount'), 1));
633 633
 			$where           .= " AND lis_postmeta2.meta_key = '_manage_stock'
634 634
 			AND lis_postmeta2.meta_value = 'yes'
635 635
 			AND lis_postmeta.meta_key = '_stock'
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 * @param object $wp_query \WP_Query object.
654 654
 	 * @return string
655 655
 	 */
656
-	public static function add_wp_query_join( $join, $wp_query ) {
656
+	public static function add_wp_query_join($join, $wp_query) {
657 657
 		global $wpdb;
658 658
 
659
-		$search = $wp_query->get( 'search' );
660
-		if ( $search && wc_product_sku_enabled() ) {
659
+		$search = $wp_query->get('search');
660
+		if ($search && wc_product_sku_enabled()) {
661 661
 			$join .= " INNER JOIN {$wpdb->postmeta} AS ps_post_meta ON ps_post_meta.post_id = {$wpdb->posts}.ID";
662 662
 		}
663 663
 
664
-		if ( $wp_query->get( 'low_in_stock' ) ) {
664
+		if ($wp_query->get('low_in_stock')) {
665 665
 			$join .= " INNER JOIN {$wpdb->postmeta} AS lis_postmeta ON {$wpdb->posts}.ID = lis_postmeta.post_id
666 666
 			INNER JOIN {$wpdb->postmeta} AS lis_postmeta2 ON {$wpdb->posts}.ID = lis_postmeta2.post_id
667 667
 			INNER JOIN {$wpdb->postmeta} AS lis_postmeta3 ON {$wpdb->posts}.ID = lis_postmeta3.post_id";
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	 * @param object $wp_query \WP_Query object.
678 678
 	 * @return string
679 679
 	 */
680
-	public static function add_wp_query_group_by( $groupby, $wp_query ) {
680
+	public static function add_wp_query_group_by($groupby, $wp_query) {
681 681
 		global $wpdb;
682 682
 
683
-		$search       = $wp_query->get( 'search' );
684
-		$low_in_stock = $wp_query->get( 'low_in_stock' );
685
-		if ( empty( $groupby ) && ( $search || $low_in_stock ) ) {
683
+		$search       = $wp_query->get('search');
684
+		$low_in_stock = $wp_query->get('low_in_stock');
685
+		if (empty($groupby) && ($search || $low_in_stock)) {
686 686
 			$groupby = $wpdb->posts . '.ID';
687 687
 		}
688 688
 		return $groupby;
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 	 * @param \WP_REST_Request $request Request data.
696 696
 	 * @return array
697 697
 	 */
698
-	protected function prepare_objects_query( $request ) {
699
-		$args = parent::prepare_objects_query( $request );
698
+	protected function prepare_objects_query($request) {
699
+		$args = parent::prepare_objects_query($request);
700 700
 
701 701
 		// Set post_status.
702 702
 		$args['post_status'] = $request['status'];
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 		);
714 714
 
715 715
 		// Set tax_query for each passed arg.
716
-		foreach ( $taxonomies as $taxonomy => $key ) {
717
-			if ( ! empty( $request[ $key ] ) ) {
716
+		foreach ($taxonomies as $taxonomy => $key) {
717
+			if ( ! empty($request[$key])) {
718 718
 				$tax_query[] = array(
719 719
 					'taxonomy' => $taxonomy,
720 720
 					'field'    => 'term_id',
721
-					'terms'    => $request[ $key ],
721
+					'terms'    => $request[$key],
722 722
 				);
723 723
 			}
724 724
 		}
725 725
 
726 726
 		// Filter product type by slug.
727
-		if ( ! empty( $request['type'] ) ) {
727
+		if ( ! empty($request['type'])) {
728 728
 			$tax_query[] = array(
729 729
 				'taxonomy' => 'product_type',
730 730
 				'field'    => 'slug',
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
 		}
734 734
 
735 735
 		// Filter by attribute and term.
736
-		if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {
737
-			if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) {
736
+		if ( ! empty($request['attribute']) && ! empty($request['attribute_term'])) {
737
+			if (in_array($request['attribute'], wc_get_attribute_taxonomy_names(), true)) {
738 738
 				$tax_query[] = array(
739 739
 					'taxonomy' => $request['attribute'],
740 740
 					'field'    => 'term_id',
@@ -744,16 +744,16 @@  discard block
 block discarded – undo
744 744
 		}
745 745
 
746 746
 		// Build tax_query if taxonomies are set.
747
-		if ( ! empty( $tax_query ) ) {
748
-			if ( ! empty( $args['tax_query'] ) ) {
749
-				$args['tax_query'] = array_merge( $tax_query, $args['tax_query'] ); // WPCS: slow query ok.
747
+		if ( ! empty($tax_query)) {
748
+			if ( ! empty($args['tax_query'])) {
749
+				$args['tax_query'] = array_merge($tax_query, $args['tax_query']); // WPCS: slow query ok.
750 750
 			} else {
751 751
 				$args['tax_query'] = $tax_query; // WPCS: slow query ok.
752 752
 			}
753 753
 		}
754 754
 
755 755
 		// Filter featured.
756
-		if ( is_bool( $request['featured'] ) ) {
756
+		if (is_bool($request['featured'])) {
757 757
 			$args['tax_query'][] = array(
758 758
 				'taxonomy' => 'product_visibility',
759 759
 				'field'    => 'name',
@@ -763,10 +763,10 @@  discard block
 block discarded – undo
763 763
 		}
764 764
 
765 765
 		// Filter by sku.
766
-		if ( ! empty( $request['sku'] ) ) {
767
-			$skus = explode( ',', $request['sku'] );
766
+		if ( ! empty($request['sku'])) {
767
+			$skus = explode(',', $request['sku']);
768 768
 			// Include the current string as a SKU too.
769
-			if ( 1 < count( $skus ) ) {
769
+			if (1 < count($skus)) {
770 770
 				$skus[] = $request['sku'];
771 771
 			}
772 772
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		}
782 782
 
783 783
 		// Filter by tax class.
784
-		if ( ! empty( $request['tax_class'] ) ) {
784
+		if ( ! empty($request['tax_class'])) {
785 785
 			$args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok.
786 786
 				$args,
787 787
 				array(
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
 		}
793 793
 
794 794
 		// Price filter.
795
-		if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) {
796
-			$args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) );  // WPCS: slow query ok.
795
+		if ( ! empty($request['min_price']) || ! empty($request['max_price'])) {
796
+			$args['meta_query'] = $this->add_meta_query($args, wc_get_min_max_price_meta_query($request)); // WPCS: slow query ok.
797 797
 		}
798 798
 
799 799
 		// Filter product by stock_status.
800
-		if ( ! empty( $request['stock_status'] ) ) {
800
+		if ( ! empty($request['stock_status'])) {
801 801
 			$args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok.
802 802
 				$args,
803 803
 				array(
@@ -808,30 +808,30 @@  discard block
 block discarded – undo
808 808
 		}
809 809
 
810 810
 		// Filter by on sale products.
811
-		if ( is_bool( $request['on_sale'] ) ) {
811
+		if (is_bool($request['on_sale'])) {
812 812
 			$on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in';
813 813
 			$on_sale_ids = wc_get_product_ids_on_sale();
814 814
 
815 815
 			// Use 0 when there's no on sale products to avoid return all products.
816
-			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
816
+			$on_sale_ids = empty($on_sale_ids) ? array(0) : $on_sale_ids;
817 817
 
818
-			$args[ $on_sale_key ] += $on_sale_ids;
818
+			$args[$on_sale_key] += $on_sale_ids;
819 819
 		}
820 820
 
821 821
 		// Force the post_type argument, since it's not a user input variable.
822
-		if ( ! empty( $request['sku'] ) ) {
823
-			$args['post_type'] = array( 'product', 'product_variation' );
822
+		if ( ! empty($request['sku'])) {
823
+			$args['post_type'] = array('product', 'product_variation');
824 824
 		} else {
825 825
 			$args['post_type'] = $this->post_type;
826 826
 		}
827 827
 
828
-		$orderby = $request->get_param( 'orderby' );
829
-		$order   = $request->get_param( 'order' );
828
+		$orderby = $request->get_param('orderby');
829
+		$order   = $request->get_param('order');
830 830
 
831
-		$ordering_args   = WC()->query->get_catalog_ordering_args( $orderby, $order );
831
+		$ordering_args   = WC()->query->get_catalog_ordering_args($orderby, $order);
832 832
 		$args['orderby'] = $ordering_args['orderby'];
833 833
 		$args['order']   = $ordering_args['order'];
834
-		if ( $ordering_args['meta_key'] ) {
834
+		if ($ordering_args['meta_key']) {
835 835
 			$args['meta_key'] = $ordering_args['meta_key']; // WPCS: slow query ok.
836 836
 		}
837 837
 
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
 	 *
846 846
 	 * @return array
847 847
 	 */
848
-	protected function get_downloads( $product ) {
848
+	protected function get_downloads($product) {
849 849
 		$downloads = array();
850 850
 
851
-		if ( $product->is_downloadable() ) {
852
-			foreach ( $product->get_downloads() as $file_id => $file ) {
851
+		if ($product->is_downloadable()) {
852
+			foreach ($product->get_downloads() as $file_id => $file) {
853 853
 				$downloads[] = array(
854 854
 					'id'   => $file_id, // MD5 hash.
855 855
 					'name' => $file['name'],
@@ -869,10 +869,10 @@  discard block
 block discarded – undo
869 869
 	 *
870 870
 	 * @return array
871 871
 	 */
872
-	protected function get_taxonomy_terms( $product, $taxonomy = 'cat' ) {
872
+	protected function get_taxonomy_terms($product, $taxonomy = 'cat') {
873 873
 		$terms = array();
874 874
 
875
-		foreach ( wc_get_object_terms( $product->get_id(), 'product_' . $taxonomy ) as $term ) {
875
+		foreach (wc_get_object_terms($product->get_id(), 'product_' . $taxonomy) as $term) {
876 876
 			$terms[] = array(
877 877
 				'id'   => $term->term_id,
878 878
 				'name' => $term->name,
@@ -889,39 +889,39 @@  discard block
 block discarded – undo
889 889
 	 * @param WC_Product|WC_Product_Variation $product Product instance.
890 890
 	 * @return array
891 891
 	 */
892
-	protected function get_images( $product ) {
892
+	protected function get_images($product) {
893 893
 		$images         = array();
894 894
 		$attachment_ids = array();
895 895
 
896 896
 		// Add featured image.
897
-		if ( $product->get_image_id() ) {
897
+		if ($product->get_image_id()) {
898 898
 			$attachment_ids[] = $product->get_image_id();
899 899
 		}
900 900
 
901 901
 		// Add gallery images.
902
-		$attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() );
902
+		$attachment_ids = array_merge($attachment_ids, $product->get_gallery_image_ids());
903 903
 
904 904
 		// Build image data.
905
-		foreach ( $attachment_ids as $attachment_id ) {
906
-			$attachment_post = get_post( $attachment_id );
907
-			if ( is_null( $attachment_post ) ) {
905
+		foreach ($attachment_ids as $attachment_id) {
906
+			$attachment_post = get_post($attachment_id);
907
+			if (is_null($attachment_post)) {
908 908
 				continue;
909 909
 			}
910 910
 
911
-			$attachment = wp_get_attachment_image_src( $attachment_id, 'full' );
912
-			if ( ! is_array( $attachment ) ) {
911
+			$attachment = wp_get_attachment_image_src($attachment_id, 'full');
912
+			if ( ! is_array($attachment)) {
913 913
 				continue;
914 914
 			}
915 915
 
916 916
 			$images[] = array(
917 917
 				'id'                => (int) $attachment_id,
918
-				'date_created'      => wc_rest_prepare_date_response( $attachment_post->post_date, false ),
919
-				'date_created_gmt'  => wc_rest_prepare_date_response( strtotime( $attachment_post->post_date_gmt ) ),
920
-				'date_modified'     => wc_rest_prepare_date_response( $attachment_post->post_modified, false ),
921
-				'date_modified_gmt' => wc_rest_prepare_date_response( strtotime( $attachment_post->post_modified_gmt ) ),
922
-				'src'               => current( $attachment ),
923
-				'name'              => get_the_title( $attachment_id ),
924
-				'alt'               => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ),
918
+				'date_created'      => wc_rest_prepare_date_response($attachment_post->post_date, false),
919
+				'date_created_gmt'  => wc_rest_prepare_date_response(strtotime($attachment_post->post_date_gmt)),
920
+				'date_modified'     => wc_rest_prepare_date_response($attachment_post->post_modified, false),
921
+				'date_modified_gmt' => wc_rest_prepare_date_response(strtotime($attachment_post->post_modified_gmt)),
922
+				'src'               => current($attachment),
923
+				'name'              => get_the_title($attachment_id),
924
+				'alt'               => get_post_meta($attachment_id, '_wp_attachment_image_alt', true),
925 925
 			);
926 926
 		}
927 927
 
@@ -936,9 +936,9 @@  discard block
 block discarded – undo
936 936
 	 * @deprecated 3.0.0
937 937
 	 * @return     string
938 938
 	 */
939
-	protected function get_attribute_taxonomy_label( $name ) {
940
-		$tax    = get_taxonomy( $name );
941
-		$labels = get_taxonomy_labels( $tax );
939
+	protected function get_attribute_taxonomy_label($name) {
940
+		$tax    = get_taxonomy($name);
941
+		$labels = get_taxonomy_labels($tax);
942 942
 
943 943
 		return $labels->singular_name;
944 944
 	}
@@ -952,25 +952,25 @@  discard block
 block discarded – undo
952 952
 	 * @since  3.0.0
953 953
 	 * @return string
954 954
 	 */
955
-	protected function get_attribute_taxonomy_name( $slug, $product ) {
955
+	protected function get_attribute_taxonomy_name($slug, $product) {
956 956
 		// Format slug so it matches attributes of the product.
957
-		$slug       = wc_attribute_taxonomy_slug( $slug );
957
+		$slug       = wc_attribute_taxonomy_slug($slug);
958 958
 		$attributes = $product->get_attributes();
959 959
 		$attribute  = false;
960 960
 
961 961
 		// pa_ attributes.
962
-		if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) {
963
-			$attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ];
964
-		} elseif ( isset( $attributes[ $slug ] ) ) {
965
-			$attribute = $attributes[ $slug ];
962
+		if (isset($attributes[wc_attribute_taxonomy_name($slug)])) {
963
+			$attribute = $attributes[wc_attribute_taxonomy_name($slug)];
964
+		} elseif (isset($attributes[$slug])) {
965
+			$attribute = $attributes[$slug];
966 966
 		}
967 967
 
968
-		if ( ! $attribute ) {
968
+		if ( ! $attribute) {
969 969
 			return $slug;
970 970
 		}
971 971
 
972 972
 		// Taxonomy attribute name.
973
-		if ( $attribute->is_taxonomy() ) {
973
+		if ($attribute->is_taxonomy()) {
974 974
 			$taxonomy = $attribute->get_taxonomy_object();
975 975
 			return $taxonomy->attribute_label;
976 976
 		}
@@ -986,21 +986,21 @@  discard block
 block discarded – undo
986 986
 	 *
987 987
 	 * @return array
988 988
 	 */
989
-	protected function get_default_attributes( $product ) {
989
+	protected function get_default_attributes($product) {
990 990
 		$default = array();
991 991
 
992
-		if ( $product->is_type( 'variable' ) ) {
993
-			foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) {
994
-				if ( 0 === strpos( $key, 'pa_' ) ) {
992
+		if ($product->is_type('variable')) {
993
+			foreach (array_filter((array) $product->get_default_attributes(), 'strlen') as $key => $value) {
994
+				if (0 === strpos($key, 'pa_')) {
995 995
 					$default[] = array(
996
-						'id'     => wc_attribute_taxonomy_id_by_name( $key ),
997
-						'name'   => $this->get_attribute_taxonomy_name( $key, $product ),
996
+						'id'     => wc_attribute_taxonomy_id_by_name($key),
997
+						'name'   => $this->get_attribute_taxonomy_name($key, $product),
998 998
 						'option' => $value,
999 999
 					);
1000 1000
 				} else {
1001 1001
 					$default[] = array(
1002 1002
 						'id'     => 0,
1003
-						'name'   => $this->get_attribute_taxonomy_name( $key, $product ),
1003
+						'name'   => $this->get_attribute_taxonomy_name($key, $product),
1004 1004
 						'option' => $value,
1005 1005
 					);
1006 1006
 				}
@@ -1018,8 +1018,8 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @return array
1020 1020
 	 */
1021
-	protected function get_attribute_options( $product_id, $attribute ) {
1022
-		if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) {
1021
+	protected function get_attribute_options($product_id, $attribute) {
1022
+		if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']) {
1023 1023
 			return wc_get_product_terms(
1024 1024
 				$product_id,
1025 1025
 				$attribute['name'],
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 					'fields' => 'names',
1028 1028
 				)
1029 1029
 			);
1030
-		} elseif ( isset( $attribute['value'] ) ) {
1031
-			return array_map( 'trim', explode( '|', $attribute['value'] ) );
1030
+		} elseif (isset($attribute['value'])) {
1031
+			return array_map('trim', explode('|', $attribute['value']));
1032 1032
 		}
1033 1033
 
1034 1034
 		return array();
@@ -1041,43 +1041,43 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return array
1043 1043
 	 */
1044
-	protected function get_attributes( $product ) {
1044
+	protected function get_attributes($product) {
1045 1045
 		$attributes = array();
1046 1046
 
1047
-		if ( $product->is_type( 'variation' ) ) {
1048
-			$_product = wc_get_product( $product->get_parent_id() );
1049
-			foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) {
1050
-				$name = str_replace( 'attribute_', '', $attribute_name );
1047
+		if ($product->is_type('variation')) {
1048
+			$_product = wc_get_product($product->get_parent_id());
1049
+			foreach ($product->get_variation_attributes() as $attribute_name => $attribute) {
1050
+				$name = str_replace('attribute_', '', $attribute_name);
1051 1051
 
1052
-				if ( empty( $attribute ) && '0' !== $attribute ) {
1052
+				if (empty($attribute) && '0' !== $attribute) {
1053 1053
 					continue;
1054 1054
 				}
1055 1055
 
1056 1056
 				// Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`.
1057
-				if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) {
1058
-					$option_term  = get_term_by( 'slug', $attribute, $name );
1057
+				if (0 === strpos($attribute_name, 'attribute_pa_')) {
1058
+					$option_term  = get_term_by('slug', $attribute, $name);
1059 1059
 					$attributes[] = array(
1060
-						'id'     => wc_attribute_taxonomy_id_by_name( $name ),
1061
-						'name'   => $this->get_attribute_taxonomy_name( $name, $_product ),
1062
-						'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute,
1060
+						'id'     => wc_attribute_taxonomy_id_by_name($name),
1061
+						'name'   => $this->get_attribute_taxonomy_name($name, $_product),
1062
+						'option' => $option_term && ! is_wp_error($option_term) ? $option_term->name : $attribute,
1063 1063
 					);
1064 1064
 				} else {
1065 1065
 					$attributes[] = array(
1066 1066
 						'id'     => 0,
1067
-						'name'   => $this->get_attribute_taxonomy_name( $name, $_product ),
1067
+						'name'   => $this->get_attribute_taxonomy_name($name, $_product),
1068 1068
 						'option' => $attribute,
1069 1069
 					);
1070 1070
 				}
1071 1071
 			}
1072 1072
 		} else {
1073
-			foreach ( $product->get_attributes() as $attribute ) {
1073
+			foreach ($product->get_attributes() as $attribute) {
1074 1074
 				$attributes[] = array(
1075
-					'id'        => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name'] ) : 0,
1076
-					'name'      => $this->get_attribute_taxonomy_name( $attribute['name'], $product ),
1075
+					'id'        => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0,
1076
+					'name'      => $this->get_attribute_taxonomy_name($attribute['name'], $product),
1077 1077
 					'position'  => (int) $attribute['position'],
1078 1078
 					'visible'   => (bool) $attribute['is_visible'],
1079 1079
 					'variation' => (bool) $attribute['is_variation'],
1080
-					'options'   => $this->get_attribute_options( $product->get_id(), $attribute ),
1080
+					'options'   => $this->get_attribute_options($product->get_id(), $attribute),
1081 1081
 				);
1082 1082
 			}
1083 1083
 		}
@@ -1094,76 +1094,76 @@  discard block
 block discarded – undo
1094 1094
 	 *
1095 1095
 	 * @return array
1096 1096
 	 */
1097
-	protected function get_product_data( $product, $context = 'view' ) {
1097
+	protected function get_product_data($product, $context = 'view') {
1098 1098
 		$data = array(
1099 1099
 			'id'                    => $product->get_id(),
1100
-			'name'                  => $product->get_name( $context ),
1101
-			'slug'                  => $product->get_slug( $context ),
1100
+			'name'                  => $product->get_name($context),
1101
+			'slug'                  => $product->get_slug($context),
1102 1102
 			'permalink'             => $product->get_permalink(),
1103
-			'date_created'          => wc_rest_prepare_date_response( $product->get_date_created( $context ), false ),
1104
-			'date_created_gmt'      => wc_rest_prepare_date_response( $product->get_date_created( $context ) ),
1105
-			'date_modified'         => wc_rest_prepare_date_response( $product->get_date_modified( $context ), false ),
1106
-			'date_modified_gmt'     => wc_rest_prepare_date_response( $product->get_date_modified( $context ) ),
1103
+			'date_created'          => wc_rest_prepare_date_response($product->get_date_created($context), false),
1104
+			'date_created_gmt'      => wc_rest_prepare_date_response($product->get_date_created($context)),
1105
+			'date_modified'         => wc_rest_prepare_date_response($product->get_date_modified($context), false),
1106
+			'date_modified_gmt'     => wc_rest_prepare_date_response($product->get_date_modified($context)),
1107 1107
 			'type'                  => $product->get_type(),
1108
-			'status'                => $product->get_status( $context ),
1108
+			'status'                => $product->get_status($context),
1109 1109
 			'featured'              => $product->is_featured(),
1110
-			'catalog_visibility'    => $product->get_catalog_visibility( $context ),
1111
-			'description'           => 'view' === $context ? wpautop( do_shortcode( $product->get_description() ) ) : $product->get_description( $context ),
1112
-			'short_description'     => 'view' === $context ? apply_filters( 'woocommerce_short_description', $product->get_short_description() ) : $product->get_short_description( $context ),
1113
-			'sku'                   => $product->get_sku( $context ),
1114
-			'price'                 => $product->get_price( $context ),
1115
-			'regular_price'         => $product->get_regular_price( $context ),
1116
-			'sale_price'            => $product->get_sale_price( $context ) ? $product->get_sale_price( $context ) : '',
1117
-			'date_on_sale_from'     => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ), false ),
1118
-			'date_on_sale_from_gmt' => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ) ),
1119
-			'date_on_sale_to'       => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ), false ),
1120
-			'date_on_sale_to_gmt'   => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ) ),
1110
+			'catalog_visibility'    => $product->get_catalog_visibility($context),
1111
+			'description'           => 'view' === $context ? wpautop(do_shortcode($product->get_description())) : $product->get_description($context),
1112
+			'short_description'     => 'view' === $context ? apply_filters('woocommerce_short_description', $product->get_short_description()) : $product->get_short_description($context),
1113
+			'sku'                   => $product->get_sku($context),
1114
+			'price'                 => $product->get_price($context),
1115
+			'regular_price'         => $product->get_regular_price($context),
1116
+			'sale_price'            => $product->get_sale_price($context) ? $product->get_sale_price($context) : '',
1117
+			'date_on_sale_from'     => wc_rest_prepare_date_response($product->get_date_on_sale_from($context), false),
1118
+			'date_on_sale_from_gmt' => wc_rest_prepare_date_response($product->get_date_on_sale_from($context)),
1119
+			'date_on_sale_to'       => wc_rest_prepare_date_response($product->get_date_on_sale_to($context), false),
1120
+			'date_on_sale_to_gmt'   => wc_rest_prepare_date_response($product->get_date_on_sale_to($context)),
1121 1121
 			'price_html'            => $product->get_price_html(),
1122
-			'on_sale'               => $product->is_on_sale( $context ),
1122
+			'on_sale'               => $product->is_on_sale($context),
1123 1123
 			'purchasable'           => $product->is_purchasable(),
1124
-			'total_sales'           => $product->get_total_sales( $context ),
1124
+			'total_sales'           => $product->get_total_sales($context),
1125 1125
 			'virtual'               => $product->is_virtual(),
1126 1126
 			'downloadable'          => $product->is_downloadable(),
1127
-			'downloads'             => $this->get_downloads( $product ),
1128
-			'download_limit'        => $product->get_download_limit( $context ),
1129
-			'download_expiry'       => $product->get_download_expiry( $context ),
1130
-			'external_url'          => $product->is_type( 'external' ) ? $product->get_product_url( $context ) : '',
1131
-			'button_text'           => $product->is_type( 'external' ) ? $product->get_button_text( $context ) : '',
1132
-			'tax_status'            => $product->get_tax_status( $context ),
1133
-			'tax_class'             => $product->get_tax_class( $context ),
1127
+			'downloads'             => $this->get_downloads($product),
1128
+			'download_limit'        => $product->get_download_limit($context),
1129
+			'download_expiry'       => $product->get_download_expiry($context),
1130
+			'external_url'          => $product->is_type('external') ? $product->get_product_url($context) : '',
1131
+			'button_text'           => $product->is_type('external') ? $product->get_button_text($context) : '',
1132
+			'tax_status'            => $product->get_tax_status($context),
1133
+			'tax_class'             => $product->get_tax_class($context),
1134 1134
 			'manage_stock'          => $product->managing_stock(),
1135
-			'stock_quantity'        => $product->get_stock_quantity( $context ),
1136
-			'stock_status'          => $product->get_stock_status( $context ),
1137
-			'backorders'            => $product->get_backorders( $context ),
1135
+			'stock_quantity'        => $product->get_stock_quantity($context),
1136
+			'stock_status'          => $product->get_stock_status($context),
1137
+			'backorders'            => $product->get_backorders($context),
1138 1138
 			'backorders_allowed'    => $product->backorders_allowed(),
1139 1139
 			'backordered'           => $product->is_on_backorder(),
1140 1140
 			'sold_individually'     => $product->is_sold_individually(),
1141
-			'weight'                => $product->get_weight( $context ),
1141
+			'weight'                => $product->get_weight($context),
1142 1142
 			'dimensions'            => array(
1143
-				'length' => $product->get_length( $context ),
1144
-				'width'  => $product->get_width( $context ),
1145
-				'height' => $product->get_height( $context ),
1143
+				'length' => $product->get_length($context),
1144
+				'width'  => $product->get_width($context),
1145
+				'height' => $product->get_height($context),
1146 1146
 			),
1147 1147
 			'shipping_required'     => $product->needs_shipping(),
1148 1148
 			'shipping_taxable'      => $product->is_shipping_taxable(),
1149 1149
 			'shipping_class'        => $product->get_shipping_class(),
1150
-			'shipping_class_id'     => $product->get_shipping_class_id( $context ),
1151
-			'reviews_allowed'       => $product->get_reviews_allowed( $context ),
1152
-			'average_rating'        => 'view' === $context ? wc_format_decimal( $product->get_average_rating(), 2 ) : $product->get_average_rating( $context ),
1150
+			'shipping_class_id'     => $product->get_shipping_class_id($context),
1151
+			'reviews_allowed'       => $product->get_reviews_allowed($context),
1152
+			'average_rating'        => 'view' === $context ? wc_format_decimal($product->get_average_rating(), 2) : $product->get_average_rating($context),
1153 1153
 			'rating_count'          => $product->get_rating_count(),
1154
-			'related_ids'           => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ),
1155
-			'upsell_ids'            => array_map( 'absint', $product->get_upsell_ids( $context ) ),
1156
-			'cross_sell_ids'        => array_map( 'absint', $product->get_cross_sell_ids( $context ) ),
1157
-			'parent_id'             => $product->get_parent_id( $context ),
1158
-			'purchase_note'         => 'view' === $context ? wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ) : $product->get_purchase_note( $context ),
1159
-			'categories'            => $this->get_taxonomy_terms( $product ),
1160
-			'tags'                  => $this->get_taxonomy_terms( $product, 'tag' ),
1161
-			'images'                => $this->get_images( $product ),
1162
-			'attributes'            => $this->get_attributes( $product ),
1163
-			'default_attributes'    => $this->get_default_attributes( $product ),
1154
+			'related_ids'           => array_map('absint', array_values(wc_get_related_products($product->get_id()))),
1155
+			'upsell_ids'            => array_map('absint', $product->get_upsell_ids($context)),
1156
+			'cross_sell_ids'        => array_map('absint', $product->get_cross_sell_ids($context)),
1157
+			'parent_id'             => $product->get_parent_id($context),
1158
+			'purchase_note'         => 'view' === $context ? wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))) : $product->get_purchase_note($context),
1159
+			'categories'            => $this->get_taxonomy_terms($product),
1160
+			'tags'                  => $this->get_taxonomy_terms($product, 'tag'),
1161
+			'images'                => $this->get_images($product),
1162
+			'attributes'            => $this->get_attributes($product),
1163
+			'default_attributes'    => $this->get_default_attributes($product),
1164 1164
 			'variations'            => array(),
1165 1165
 			'grouped_products'      => array(),
1166
-			'menu_order'            => $product->get_menu_order( $context ),
1166
+			'menu_order'            => $product->get_menu_order($context),
1167 1167
 			'meta_data'             => $product->get_meta_data(),
1168 1168
 		);
1169 1169
 
@@ -1178,19 +1178,19 @@  discard block
 block discarded – undo
1178 1178
 	 *
1179 1179
 	 * @return array                   Links for the given post.
1180 1180
 	 */
1181
-	protected function prepare_links( $object, $request ) {
1181
+	protected function prepare_links($object, $request) {
1182 1182
 		$links = array(
1183 1183
 			'self'       => array(
1184
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),  // @codingStandardsIgnoreLine.
1184
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())), // @codingStandardsIgnoreLine.
1185 1185
 			),
1186 1186
 			'collection' => array(
1187
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),  // @codingStandardsIgnoreLine.
1187
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)), // @codingStandardsIgnoreLine.
1188 1188
 			),
1189 1189
 		);
1190 1190
 
1191
-		if ( $object->get_parent_id() ) {
1191
+		if ($object->get_parent_id()) {
1192 1192
 			$links['up'] = array(
1193
-				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ),  // @codingStandardsIgnoreLine.
1193
+				'href' => rest_url(sprintf('/%s/products/%d', $this->namespace, $object->get_parent_id())), // @codingStandardsIgnoreLine.
1194 1194
 			);
1195 1195
 		}
1196 1196
 
@@ -1206,49 +1206,49 @@  discard block
 block discarded – undo
1206 1206
 	 * @param array      $images  Images data.
1207 1207
 	 * @return WC_Product
1208 1208
 	 */
1209
-	protected function set_product_images( $product, $images ) {
1210
-		$images = is_array( $images ) ? array_filter( $images ) : array();
1209
+	protected function set_product_images($product, $images) {
1210
+		$images = is_array($images) ? array_filter($images) : array();
1211 1211
 
1212
-		if ( ! empty( $images ) ) {
1212
+		if ( ! empty($images)) {
1213 1213
 			$gallery = array();
1214 1214
 
1215
-			foreach ( $images as $index => $image ) {
1216
-				$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
1215
+			foreach ($images as $index => $image) {
1216
+				$attachment_id = isset($image['id']) ? absint($image['id']) : 0;
1217 1217
 
1218
-				if ( 0 === $attachment_id && isset( $image['src'] ) ) {
1219
-					$upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) );
1218
+				if (0 === $attachment_id && isset($image['src'])) {
1219
+					$upload = wc_rest_upload_image_from_url(esc_url_raw($image['src']));
1220 1220
 
1221
-					if ( is_wp_error( $upload ) ) {
1222
-						if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images ) ) {
1223
-							throw new \WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 );
1221
+					if (is_wp_error($upload)) {
1222
+						if ( ! apply_filters('woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images)) {
1223
+							throw new \WC_REST_Exception('woocommerce_product_image_upload_error', $upload->get_error_message(), 400);
1224 1224
 						} else {
1225 1225
 							continue;
1226 1226
 						}
1227 1227
 					}
1228 1228
 
1229
-					$attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product->get_id() );
1229
+					$attachment_id = wc_rest_set_uploaded_image_as_attachment($upload, $product->get_id());
1230 1230
 				}
1231 1231
 
1232
-				if ( ! wp_attachment_is_image( $attachment_id ) ) {
1232
+				if ( ! wp_attachment_is_image($attachment_id)) {
1233 1233
 					/* translators: %s: image ID */
1234
-					throw new \WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
1234
+					throw new \WC_REST_Exception('woocommerce_product_invalid_image_id', sprintf(__('#%s is an invalid image ID.', 'woocommerce'), $attachment_id), 400);
1235 1235
 				}
1236 1236
 
1237 1237
 				$featured_image = $product->get_image_id();
1238 1238
 
1239
-				if ( 0 === $index ) {
1240
-					$product->set_image_id( $attachment_id );
1239
+				if (0 === $index) {
1240
+					$product->set_image_id($attachment_id);
1241 1241
 				} else {
1242 1242
 					$gallery[] = $attachment_id;
1243 1243
 				}
1244 1244
 
1245 1245
 				// Set the image alt if present.
1246
-				if ( ! empty( $image['alt'] ) ) {
1247
-					update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) );
1246
+				if ( ! empty($image['alt'])) {
1247
+					update_post_meta($attachment_id, '_wp_attachment_image_alt', wc_clean($image['alt']));
1248 1248
 				}
1249 1249
 
1250 1250
 				// Set the image name if present.
1251
-				if ( ! empty( $image['name'] ) ) {
1251
+				if ( ! empty($image['name'])) {
1252 1252
 					wp_update_post(
1253 1253
 						array(
1254 1254
 							'ID'         => $attachment_id,
@@ -1258,10 +1258,10 @@  discard block
 block discarded – undo
1258 1258
 				}
1259 1259
 			}
1260 1260
 
1261
-			$product->set_gallery_image_ids( $gallery );
1261
+			$product->set_gallery_image_ids($gallery);
1262 1262
 		} else {
1263
-			$product->set_image_id( '' );
1264
-			$product->set_gallery_image_ids( array() );
1263
+			$product->set_image_id('');
1264
+			$product->set_gallery_image_ids(array());
1265 1265
 		}
1266 1266
 
1267 1267
 		return $product;
@@ -1275,39 +1275,39 @@  discard block
 block discarded – undo
1275 1275
 	 *
1276 1276
 	 * @return WC_Product
1277 1277
 	 */
1278
-	protected function save_product_shipping_data( $product, $data ) {
1278
+	protected function save_product_shipping_data($product, $data) {
1279 1279
 		// Virtual.
1280
-		if ( isset( $data['virtual'] ) && true === $data['virtual'] ) {
1281
-			$product->set_weight( '' );
1282
-			$product->set_height( '' );
1283
-			$product->set_length( '' );
1284
-			$product->set_width( '' );
1280
+		if (isset($data['virtual']) && true === $data['virtual']) {
1281
+			$product->set_weight('');
1282
+			$product->set_height('');
1283
+			$product->set_length('');
1284
+			$product->set_width('');
1285 1285
 		} else {
1286
-			if ( isset( $data['weight'] ) ) {
1287
-				$product->set_weight( $data['weight'] );
1286
+			if (isset($data['weight'])) {
1287
+				$product->set_weight($data['weight']);
1288 1288
 			}
1289 1289
 
1290 1290
 			// Height.
1291
-			if ( isset( $data['dimensions']['height'] ) ) {
1292
-				$product->set_height( $data['dimensions']['height'] );
1291
+			if (isset($data['dimensions']['height'])) {
1292
+				$product->set_height($data['dimensions']['height']);
1293 1293
 			}
1294 1294
 
1295 1295
 			// Width.
1296
-			if ( isset( $data['dimensions']['width'] ) ) {
1297
-				$product->set_width( $data['dimensions']['width'] );
1296
+			if (isset($data['dimensions']['width'])) {
1297
+				$product->set_width($data['dimensions']['width']);
1298 1298
 			}
1299 1299
 
1300 1300
 			// Length.
1301
-			if ( isset( $data['dimensions']['length'] ) ) {
1302
-				$product->set_length( $data['dimensions']['length'] );
1301
+			if (isset($data['dimensions']['length'])) {
1302
+				$product->set_length($data['dimensions']['length']);
1303 1303
 			}
1304 1304
 		}
1305 1305
 
1306 1306
 		// Shipping class.
1307
-		if ( isset( $data['shipping_class'] ) ) {
1307
+		if (isset($data['shipping_class'])) {
1308 1308
 			$data_store        = $product->get_data_store();
1309
-			$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
1310
-			$product->set_shipping_class_id( $shipping_class_id );
1309
+			$shipping_class_id = $data_store->get_shipping_class_id_by_slug(wc_clean($data['shipping_class']));
1310
+			$product->set_shipping_class_id($shipping_class_id);
1311 1311
 		}
1312 1312
 
1313 1313
 		return $product;
@@ -1322,24 +1322,24 @@  discard block
 block discarded – undo
1322 1322
 	 *
1323 1323
 	 * @return WC_Product
1324 1324
 	 */
1325
-	protected function save_downloadable_files( $product, $downloads, $deprecated = 0 ) {
1326
-		if ( $deprecated ) {
1327
-			wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.' );
1325
+	protected function save_downloadable_files($product, $downloads, $deprecated = 0) {
1326
+		if ($deprecated) {
1327
+			wc_deprecated_argument('variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.');
1328 1328
 		}
1329 1329
 
1330 1330
 		$files = array();
1331
-		foreach ( $downloads as $key => $file ) {
1332
-			if ( empty( $file['file'] ) ) {
1331
+		foreach ($downloads as $key => $file) {
1332
+			if (empty($file['file'])) {
1333 1333
 				continue;
1334 1334
 			}
1335 1335
 
1336 1336
 			$download = new \WC_Product_Download();
1337
-			$download->set_id( ! empty( $file['id'] ) ? $file['id'] : wp_generate_uuid4() );
1338
-			$download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) );
1339
-			$download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) );
1337
+			$download->set_id( ! empty($file['id']) ? $file['id'] : wp_generate_uuid4());
1338
+			$download->set_name($file['name'] ? $file['name'] : wc_get_filename_from_url($file['file']));
1339
+			$download->set_file(apply_filters('woocommerce_file_download_path', $file['file'], $product, $key));
1340 1340
 			$files[] = $download;
1341 1341
 		}
1342
-		$product->set_downloads( $files );
1342
+		$product->set_downloads($files);
1343 1343
 
1344 1344
 		return $product;
1345 1345
 	}
@@ -1353,13 +1353,13 @@  discard block
 block discarded – undo
1353 1353
 	 *
1354 1354
 	 * @return WC_Product
1355 1355
 	 */
1356
-	protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) {
1357
-		$term_ids = wp_list_pluck( $terms, 'id' );
1356
+	protected function save_taxonomy_terms($product, $terms, $taxonomy = 'cat') {
1357
+		$term_ids = wp_list_pluck($terms, 'id');
1358 1358
 
1359
-		if ( 'cat' === $taxonomy ) {
1360
-			$product->set_category_ids( $term_ids );
1361
-		} elseif ( 'tag' === $taxonomy ) {
1362
-			$product->set_tag_ids( $term_ids );
1359
+		if ('cat' === $taxonomy) {
1360
+			$product->set_category_ids($term_ids);
1361
+		} elseif ('tag' === $taxonomy) {
1362
+			$product->set_tag_ids($term_ids);
1363 1363
 		}
1364 1364
 
1365 1365
 		return $product;
@@ -1372,53 +1372,53 @@  discard block
 block discarded – undo
1372 1372
 	 * @param \WP_REST_Request $request Request data.
1373 1373
 	 * @return \WC_Product
1374 1374
 	 */
1375
-	protected function save_default_attributes( $product, $request ) {
1376
-		if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
1375
+	protected function save_default_attributes($product, $request) {
1376
+		if (isset($request['default_attributes']) && is_array($request['default_attributes'])) {
1377 1377
 
1378 1378
 			$attributes         = $product->get_attributes();
1379 1379
 			$default_attributes = array();
1380 1380
 
1381
-			foreach ( $request['default_attributes'] as $attribute ) {
1381
+			foreach ($request['default_attributes'] as $attribute) {
1382 1382
 				$attribute_id   = 0;
1383 1383
 				$attribute_name = '';
1384 1384
 
1385 1385
 				// Check ID for global attributes or name for product attributes.
1386
-				if ( ! empty( $attribute['id'] ) ) {
1387
-					$attribute_id   = absint( $attribute['id'] );
1388
-					$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
1389
-				} elseif ( ! empty( $attribute['name'] ) ) {
1390
-					$attribute_name = sanitize_title( $attribute['name'] );
1386
+				if ( ! empty($attribute['id'])) {
1387
+					$attribute_id   = absint($attribute['id']);
1388
+					$attribute_name = wc_attribute_taxonomy_name_by_id($attribute_id);
1389
+				} elseif ( ! empty($attribute['name'])) {
1390
+					$attribute_name = sanitize_title($attribute['name']);
1391 1391
 				}
1392 1392
 
1393
-				if ( ! $attribute_id && ! $attribute_name ) {
1393
+				if ( ! $attribute_id && ! $attribute_name) {
1394 1394
 					continue;
1395 1395
 				}
1396 1396
 
1397
-				if ( isset( $attributes[ $attribute_name ] ) ) {
1398
-					$_attribute = $attributes[ $attribute_name ];
1397
+				if (isset($attributes[$attribute_name])) {
1398
+					$_attribute = $attributes[$attribute_name];
1399 1399
 
1400
-					if ( $_attribute['is_variation'] ) {
1401
-						$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
1400
+					if ($_attribute['is_variation']) {
1401
+						$value = isset($attribute['option']) ? wc_clean(stripslashes($attribute['option'])) : '';
1402 1402
 
1403
-						if ( ! empty( $_attribute['is_taxonomy'] ) ) {
1403
+						if ( ! empty($_attribute['is_taxonomy'])) {
1404 1404
 							// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
1405
-							$term = get_term_by( 'name', $value, $attribute_name );
1405
+							$term = get_term_by('name', $value, $attribute_name);
1406 1406
 
1407
-							if ( $term && ! is_wp_error( $term ) ) {
1407
+							if ($term && ! is_wp_error($term)) {
1408 1408
 								$value = $term->slug;
1409 1409
 							} else {
1410
-								$value = sanitize_title( $value );
1410
+								$value = sanitize_title($value);
1411 1411
 							}
1412 1412
 						}
1413 1413
 
1414
-						if ( $value ) {
1415
-							$default_attributes[ $attribute_name ] = $value;
1414
+						if ($value) {
1415
+							$default_attributes[$attribute_name] = $value;
1416 1416
 						}
1417 1417
 					}
1418 1418
 				}
1419 1419
 			}
1420 1420
 
1421
-			$product->set_default_attributes( $default_attributes );
1421
+			$product->set_default_attributes($default_attributes);
1422 1422
 		}
1423 1423
 
1424 1424
 		return $product;
@@ -1429,9 +1429,9 @@  discard block
 block discarded – undo
1429 1429
 	 *
1430 1430
 	 * @param WC_Data $object Object data.
1431 1431
 	 */
1432
-	public function clear_transients( $object ) {
1433
-		wc_delete_product_transients( $object->get_id() );
1434
-		wp_cache_delete( 'product-' . $object->get_id(), 'products' );
1432
+	public function clear_transients($object) {
1433
+		wc_delete_product_transients($object->get_id());
1434
+		wp_cache_delete('product-' . $object->get_id(), 'products');
1435 1435
 	}
1436 1436
 
1437 1437
 	/**
@@ -1441,33 +1441,33 @@  discard block
 block discarded – undo
1441 1441
 	 *
1442 1442
 	 * @return \WP_REST_Response|\WP_Error
1443 1443
 	 */
1444
-	public function delete_item( $request ) {
1444
+	public function delete_item($request) {
1445 1445
 		$id     = (int) $request['id'];
1446 1446
 		$force  = (bool) $request['force'];
1447
-		$object = $this->get_object( (int) $request['id'] );
1447
+		$object = $this->get_object((int) $request['id']);
1448 1448
 		$result = false;
1449 1449
 
1450
-		if ( ! $object || 0 === $object->get_id() ) {
1450
+		if ( ! $object || 0 === $object->get_id()) {
1451 1451
 			return new \WP_Error(
1452 1452
 				"woocommerce_rest_{$this->post_type}_invalid_id",
1453
-				__( 'Invalid ID.', 'woocommerce' ),
1453
+				__('Invalid ID.', 'woocommerce'),
1454 1454
 				array(
1455 1455
 					'status' => 404,
1456 1456
 				)
1457 1457
 			);
1458 1458
 		}
1459 1459
 
1460
-		if ( 'variation' === $object->get_type() ) {
1460
+		if ('variation' === $object->get_type()) {
1461 1461
 			return new \WP_Error(
1462 1462
 				"woocommerce_rest_invalid_{$this->post_type}_id",
1463
-				__( 'To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce' ),
1463
+				__('To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce'),
1464 1464
 				array(
1465 1465
 					'status' => 404,
1466 1466
 				)
1467 1467
 			);
1468 1468
 		}
1469 1469
 
1470
-		$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) );
1470
+		$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable(array($object, 'get_status'));
1471 1471
 
1472 1472
 		/**
1473 1473
 		 * Filter whether an object is trashable.
@@ -1477,26 +1477,26 @@  discard block
 block discarded – undo
1477 1477
 		 * @param boolean $supports_trash Whether the object type support trashing.
1478 1478
 		 * @param WC_Data $object         The object being considered for trashing support.
1479 1479
 		 */
1480
-		$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );
1480
+		$supports_trash = apply_filters("woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object);
1481 1481
 
1482
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
1482
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'delete', $object->get_id())) {
1483 1483
 			return new \WP_Error(
1484 1484
 				"woocommerce_rest_user_cannot_delete_{$this->post_type}",
1485 1485
 				/* translators: %s: post type */
1486
-				sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ),
1486
+				sprintf(__('Sorry, you are not allowed to delete %s.', 'woocommerce'), $this->post_type),
1487 1487
 				array(
1488 1488
 					'status' => rest_authorization_required_code(),
1489 1489
 				)
1490 1490
 			);
1491 1491
 		}
1492 1492
 
1493
-		$request->set_param( 'context', 'edit' );
1493
+		$request->set_param('context', 'edit');
1494 1494
 
1495 1495
 		// If we're forcing, then delete permanently.
1496
-		if ( $force ) {
1497
-			$previous = $this->prepare_object_for_response( $object, $request );
1496
+		if ($force) {
1497
+			$previous = $this->prepare_object_for_response($object, $request);
1498 1498
 
1499
-			$object->delete( true );
1499
+			$object->delete(true);
1500 1500
 			$result = 0 === $object->get_id();
1501 1501
 
1502 1502
 			$response = new \WP_REST_Response();
@@ -1508,11 +1508,11 @@  discard block
 block discarded – undo
1508 1508
 			);
1509 1509
 		} else {
1510 1510
 			// If we don't support trashing for this type, error out.
1511
-			if ( ! $supports_trash ) {
1511
+			if ( ! $supports_trash) {
1512 1512
 				return new \WP_Error(
1513 1513
 					'woocommerce_rest_trash_not_supported',
1514 1514
 					/* translators: %s: post type */
1515
-					sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ),
1515
+					sprintf(__('The %s does not support trashing.', 'woocommerce'), $this->post_type),
1516 1516
 					array(
1517 1517
 						'status' => 501,
1518 1518
 					)
@@ -1520,12 +1520,12 @@  discard block
 block discarded – undo
1520 1520
 			}
1521 1521
 
1522 1522
 			// Otherwise, only trash if we haven't already.
1523
-			if ( is_callable( array( $object, 'get_status' ) ) ) {
1524
-				if ( 'trash' === $object->get_status() ) {
1523
+			if (is_callable(array($object, 'get_status'))) {
1524
+				if ('trash' === $object->get_status()) {
1525 1525
 					return new \WP_Error(
1526 1526
 						'woocommerce_rest_already_trashed',
1527 1527
 						/* translators: %s: post type */
1528
-						sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ),
1528
+						sprintf(__('The %s has already been deleted.', 'woocommerce'), $this->post_type),
1529 1529
 						array(
1530 1530
 							'status' => 410,
1531 1531
 						)
@@ -1536,14 +1536,14 @@  discard block
 block discarded – undo
1536 1536
 				$result = 'trash' === $object->get_status();
1537 1537
 			}
1538 1538
 
1539
-			$response = $this->prepare_object_for_response( $object, $request );
1539
+			$response = $this->prepare_object_for_response($object, $request);
1540 1540
 		}
1541 1541
 
1542
-		if ( ! $result ) {
1542
+		if ( ! $result) {
1543 1543
 			return new \WP_Error(
1544 1544
 				'woocommerce_rest_cannot_delete',
1545 1545
 				/* translators: %s: post type */
1546
-				sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ),
1546
+				sprintf(__('The %s cannot be deleted.', 'woocommerce'), $this->post_type),
1547 1547
 				array(
1548 1548
 					'status' => 500,
1549 1549
 				)
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 		 * @param \WP_REST_Response $response The response data.
1558 1558
 		 * @param \WP_REST_Request  $request  The request sent to the API.
1559 1559
 		 */
1560
-		do_action( "woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request );
1560
+		do_action("woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request);
1561 1561
 
1562 1562
 		return $response;
1563 1563
 	}
@@ -1568,613 +1568,613 @@  discard block
 block discarded – undo
1568 1568
 	 * @return array
1569 1569
 	 */
1570 1570
 	public function get_item_schema() {
1571
-		$weight_unit    = get_option( 'woocommerce_weight_unit' );
1572
-		$dimension_unit = get_option( 'woocommerce_dimension_unit' );
1571
+		$weight_unit    = get_option('woocommerce_weight_unit');
1572
+		$dimension_unit = get_option('woocommerce_dimension_unit');
1573 1573
 		$schema         = array(
1574 1574
 			'$schema'    => 'http://json-schema.org/draft-04/schema#',
1575 1575
 			'title'      => $this->post_type,
1576 1576
 			'type'       => 'object',
1577 1577
 			'properties' => array(
1578 1578
 				'id'                    => array(
1579
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
1579
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
1580 1580
 					'type'        => 'integer',
1581
-					'context'     => array( 'view', 'edit', 'embed' ),
1581
+					'context'     => array('view', 'edit', 'embed'),
1582 1582
 					'readonly'    => true,
1583 1583
 				),
1584 1584
 				'name'                  => array(
1585
-					'description' => __( 'Product name.', 'woocommerce' ),
1585
+					'description' => __('Product name.', 'woocommerce'),
1586 1586
 					'type'        => 'string',
1587
-					'context'     => array( 'view', 'edit', 'embed' ),
1587
+					'context'     => array('view', 'edit', 'embed'),
1588 1588
 				),
1589 1589
 				'slug'                  => array(
1590
-					'description' => __( 'Product slug.', 'woocommerce' ),
1590
+					'description' => __('Product slug.', 'woocommerce'),
1591 1591
 					'type'        => 'string',
1592
-					'context'     => array( 'view', 'edit', 'embed' ),
1592
+					'context'     => array('view', 'edit', 'embed'),
1593 1593
 				),
1594 1594
 				'permalink'             => array(
1595
-					'description' => __( 'Product URL.', 'woocommerce' ),
1595
+					'description' => __('Product URL.', 'woocommerce'),
1596 1596
 					'type'        => 'string',
1597 1597
 					'format'      => 'uri',
1598
-					'context'     => array( 'view', 'edit', 'embed' ),
1598
+					'context'     => array('view', 'edit', 'embed'),
1599 1599
 					'readonly'    => true,
1600 1600
 				),
1601 1601
 				'date_created'          => array(
1602
-					'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ),
1602
+					'description' => __("The date the product was created, in the site's timezone.", 'woocommerce'),
1603 1603
 					'type'        => 'date-time',
1604
-					'context'     => array( 'view', 'edit' ),
1604
+					'context'     => array('view', 'edit'),
1605 1605
 				),
1606 1606
 				'date_created_gmt'      => array(
1607
-					'description' => __( 'The date the product was created, as GMT.', 'woocommerce' ),
1607
+					'description' => __('The date the product was created, as GMT.', 'woocommerce'),
1608 1608
 					'type'        => 'date-time',
1609
-					'context'     => array( 'view', 'edit' ),
1609
+					'context'     => array('view', 'edit'),
1610 1610
 				),
1611 1611
 				'date_modified'         => array(
1612
-					'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ),
1612
+					'description' => __("The date the product was last modified, in the site's timezone.", 'woocommerce'),
1613 1613
 					'type'        => 'date-time',
1614
-					'context'     => array( 'view', 'edit' ),
1614
+					'context'     => array('view', 'edit'),
1615 1615
 					'readonly'    => true,
1616 1616
 				),
1617 1617
 				'date_modified_gmt'     => array(
1618
-					'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce' ),
1618
+					'description' => __('The date the product was last modified, as GMT.', 'woocommerce'),
1619 1619
 					'type'        => 'date-time',
1620
-					'context'     => array( 'view', 'edit' ),
1620
+					'context'     => array('view', 'edit'),
1621 1621
 					'readonly'    => true,
1622 1622
 				),
1623 1623
 				'type'                  => array(
1624
-					'description' => __( 'Product type.', 'woocommerce' ),
1624
+					'description' => __('Product type.', 'woocommerce'),
1625 1625
 					'type'        => 'string',
1626 1626
 					'default'     => 'simple',
1627
-					'enum'        => array_keys( wc_get_product_types() ),
1628
-					'context'     => array( 'view', 'edit' ),
1627
+					'enum'        => array_keys(wc_get_product_types()),
1628
+					'context'     => array('view', 'edit'),
1629 1629
 				),
1630 1630
 				'status'                => array(
1631
-					'description' => __( 'Product status (post status).', 'woocommerce' ),
1631
+					'description' => __('Product status (post status).', 'woocommerce'),
1632 1632
 					'type'        => 'string',
1633 1633
 					'default'     => 'publish',
1634
-					'enum'        => array_merge( array_keys( get_post_statuses() ), array( 'future' ) ),
1635
-					'context'     => array( 'view', 'edit' ),
1634
+					'enum'        => array_merge(array_keys(get_post_statuses()), array('future')),
1635
+					'context'     => array('view', 'edit'),
1636 1636
 				),
1637 1637
 				'featured'              => array(
1638
-					'description' => __( 'Featured product.', 'woocommerce' ),
1638
+					'description' => __('Featured product.', 'woocommerce'),
1639 1639
 					'type'        => 'boolean',
1640 1640
 					'default'     => false,
1641
-					'context'     => array( 'view', 'edit' ),
1641
+					'context'     => array('view', 'edit'),
1642 1642
 				),
1643 1643
 				'catalog_visibility'    => array(
1644
-					'description' => __( 'Catalog visibility.', 'woocommerce' ),
1644
+					'description' => __('Catalog visibility.', 'woocommerce'),
1645 1645
 					'type'        => 'string',
1646 1646
 					'default'     => 'visible',
1647
-					'enum'        => array( 'visible', 'catalog', 'search', 'hidden' ),
1648
-					'context'     => array( 'view', 'edit' ),
1647
+					'enum'        => array('visible', 'catalog', 'search', 'hidden'),
1648
+					'context'     => array('view', 'edit'),
1649 1649
 				),
1650 1650
 				'description'           => array(
1651
-					'description' => __( 'Product description.', 'woocommerce' ),
1651
+					'description' => __('Product description.', 'woocommerce'),
1652 1652
 					'type'        => 'string',
1653
-					'context'     => array( 'view', 'edit', 'embed' ),
1653
+					'context'     => array('view', 'edit', 'embed'),
1654 1654
 				),
1655 1655
 				'short_description'     => array(
1656
-					'description' => __( 'Product short description.', 'woocommerce' ),
1656
+					'description' => __('Product short description.', 'woocommerce'),
1657 1657
 					'type'        => 'string',
1658
-					'context'     => array( 'view', 'edit', 'embed' ),
1658
+					'context'     => array('view', 'edit', 'embed'),
1659 1659
 				),
1660 1660
 				'sku'                   => array(
1661
-					'description' => __( 'Unique identifier.', 'woocommerce' ),
1661
+					'description' => __('Unique identifier.', 'woocommerce'),
1662 1662
 					'type'        => 'string',
1663
-					'context'     => array( 'view', 'edit' ),
1663
+					'context'     => array('view', 'edit'),
1664 1664
 				),
1665 1665
 				'price'                 => array(
1666
-					'description' => __( 'Current product price.', 'woocommerce' ),
1666
+					'description' => __('Current product price.', 'woocommerce'),
1667 1667
 					'type'        => 'string',
1668
-					'context'     => array( 'view', 'edit' ),
1668
+					'context'     => array('view', 'edit'),
1669 1669
 					'readonly'    => true,
1670 1670
 				),
1671 1671
 				'regular_price'         => array(
1672
-					'description' => __( 'Product regular price.', 'woocommerce' ),
1672
+					'description' => __('Product regular price.', 'woocommerce'),
1673 1673
 					'type'        => 'string',
1674
-					'context'     => array( 'view', 'edit' ),
1674
+					'context'     => array('view', 'edit'),
1675 1675
 				),
1676 1676
 				'sale_price'            => array(
1677
-					'description' => __( 'Product sale price.', 'woocommerce' ),
1677
+					'description' => __('Product sale price.', 'woocommerce'),
1678 1678
 					'type'        => 'string',
1679
-					'context'     => array( 'view', 'edit' ),
1679
+					'context'     => array('view', 'edit'),
1680 1680
 				),
1681 1681
 				'date_on_sale_from'     => array(
1682
-					'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
1682
+					'description' => __("Start date of sale price, in the site's timezone.", 'woocommerce'),
1683 1683
 					'type'        => 'date-time',
1684
-					'context'     => array( 'view', 'edit' ),
1684
+					'context'     => array('view', 'edit'),
1685 1685
 				),
1686 1686
 				'date_on_sale_from_gmt' => array(
1687
-					'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
1687
+					'description' => __('Start date of sale price, as GMT.', 'woocommerce'),
1688 1688
 					'type'        => 'date-time',
1689
-					'context'     => array( 'view', 'edit' ),
1689
+					'context'     => array('view', 'edit'),
1690 1690
 				),
1691 1691
 				'date_on_sale_to'       => array(
1692
-					'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
1692
+					'description' => __("End date of sale price, in the site's timezone.", 'woocommerce'),
1693 1693
 					'type'        => 'date-time',
1694
-					'context'     => array( 'view', 'edit' ),
1694
+					'context'     => array('view', 'edit'),
1695 1695
 				),
1696 1696
 				'date_on_sale_to_gmt'   => array(
1697
-					'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
1697
+					'description' => __("End date of sale price, in the site's timezone.", 'woocommerce'),
1698 1698
 					'type'        => 'date-time',
1699
-					'context'     => array( 'view', 'edit' ),
1699
+					'context'     => array('view', 'edit'),
1700 1700
 				),
1701 1701
 				'price_html'            => array(
1702
-					'description' => __( 'Price formatted in HTML.', 'woocommerce' ),
1702
+					'description' => __('Price formatted in HTML.', 'woocommerce'),
1703 1703
 					'type'        => 'string',
1704
-					'context'     => array( 'view', 'edit' ),
1704
+					'context'     => array('view', 'edit'),
1705 1705
 					'readonly'    => true,
1706 1706
 				),
1707 1707
 				'on_sale'               => array(
1708
-					'description' => __( 'Shows if the product is on sale.', 'woocommerce' ),
1708
+					'description' => __('Shows if the product is on sale.', 'woocommerce'),
1709 1709
 					'type'        => 'boolean',
1710
-					'context'     => array( 'view', 'edit' ),
1710
+					'context'     => array('view', 'edit'),
1711 1711
 					'readonly'    => true,
1712 1712
 				),
1713 1713
 				'purchasable'           => array(
1714
-					'description' => __( 'Shows if the product can be bought.', 'woocommerce' ),
1714
+					'description' => __('Shows if the product can be bought.', 'woocommerce'),
1715 1715
 					'type'        => 'boolean',
1716
-					'context'     => array( 'view', 'edit' ),
1716
+					'context'     => array('view', 'edit'),
1717 1717
 					'readonly'    => true,
1718 1718
 				),
1719 1719
 				'total_sales'           => array(
1720
-					'description' => __( 'Amount of sales.', 'woocommerce' ),
1720
+					'description' => __('Amount of sales.', 'woocommerce'),
1721 1721
 					'type'        => 'integer',
1722
-					'context'     => array( 'view', 'edit' ),
1722
+					'context'     => array('view', 'edit'),
1723 1723
 					'readonly'    => true,
1724 1724
 				),
1725 1725
 				'virtual'               => array(
1726
-					'description' => __( 'If the product is virtual.', 'woocommerce' ),
1726
+					'description' => __('If the product is virtual.', 'woocommerce'),
1727 1727
 					'type'        => 'boolean',
1728 1728
 					'default'     => false,
1729
-					'context'     => array( 'view', 'edit' ),
1729
+					'context'     => array('view', 'edit'),
1730 1730
 				),
1731 1731
 				'downloadable'          => array(
1732
-					'description' => __( 'If the product is downloadable.', 'woocommerce' ),
1732
+					'description' => __('If the product is downloadable.', 'woocommerce'),
1733 1733
 					'type'        => 'boolean',
1734 1734
 					'default'     => false,
1735
-					'context'     => array( 'view', 'edit' ),
1735
+					'context'     => array('view', 'edit'),
1736 1736
 				),
1737 1737
 				'downloads'             => array(
1738
-					'description' => __( 'List of downloadable files.', 'woocommerce' ),
1738
+					'description' => __('List of downloadable files.', 'woocommerce'),
1739 1739
 					'type'        => 'array',
1740
-					'context'     => array( 'view', 'edit' ),
1740
+					'context'     => array('view', 'edit'),
1741 1741
 					'items'       => array(
1742 1742
 						'type'       => 'object',
1743 1743
 						'properties' => array(
1744 1744
 							'id'   => array(
1745
-								'description' => __( 'File ID.', 'woocommerce' ),
1745
+								'description' => __('File ID.', 'woocommerce'),
1746 1746
 								'type'        => 'string',
1747
-								'context'     => array( 'view', 'edit' ),
1747
+								'context'     => array('view', 'edit'),
1748 1748
 							),
1749 1749
 							'name' => array(
1750
-								'description' => __( 'File name.', 'woocommerce' ),
1750
+								'description' => __('File name.', 'woocommerce'),
1751 1751
 								'type'        => 'string',
1752
-								'context'     => array( 'view', 'edit' ),
1752
+								'context'     => array('view', 'edit'),
1753 1753
 							),
1754 1754
 							'file' => array(
1755
-								'description' => __( 'File URL.', 'woocommerce' ),
1755
+								'description' => __('File URL.', 'woocommerce'),
1756 1756
 								'type'        => 'string',
1757
-								'context'     => array( 'view', 'edit' ),
1757
+								'context'     => array('view', 'edit'),
1758 1758
 							),
1759 1759
 						),
1760 1760
 					),
1761 1761
 				),
1762 1762
 				'download_limit'        => array(
1763
-					'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
1763
+					'description' => __('Number of times downloadable files can be downloaded after purchase.', 'woocommerce'),
1764 1764
 					'type'        => 'integer',
1765 1765
 					'default'     => -1,
1766
-					'context'     => array( 'view', 'edit' ),
1766
+					'context'     => array('view', 'edit'),
1767 1767
 				),
1768 1768
 				'download_expiry'       => array(
1769
-					'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
1769
+					'description' => __('Number of days until access to downloadable files expires.', 'woocommerce'),
1770 1770
 					'type'        => 'integer',
1771 1771
 					'default'     => -1,
1772
-					'context'     => array( 'view', 'edit' ),
1772
+					'context'     => array('view', 'edit'),
1773 1773
 				),
1774 1774
 				'external_url'          => array(
1775
-					'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ),
1775
+					'description' => __('Product external URL. Only for external products.', 'woocommerce'),
1776 1776
 					'type'        => 'string',
1777 1777
 					'format'      => 'uri',
1778
-					'context'     => array( 'view', 'edit' ),
1778
+					'context'     => array('view', 'edit'),
1779 1779
 				),
1780 1780
 				'button_text'           => array(
1781
-					'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ),
1781
+					'description' => __('Product external button text. Only for external products.', 'woocommerce'),
1782 1782
 					'type'        => 'string',
1783
-					'context'     => array( 'view', 'edit' ),
1783
+					'context'     => array('view', 'edit'),
1784 1784
 				),
1785 1785
 				'tax_status'            => array(
1786
-					'description' => __( 'Tax status.', 'woocommerce' ),
1786
+					'description' => __('Tax status.', 'woocommerce'),
1787 1787
 					'type'        => 'string',
1788 1788
 					'default'     => 'taxable',
1789
-					'enum'        => array( 'taxable', 'shipping', 'none' ),
1790
-					'context'     => array( 'view', 'edit' ),
1789
+					'enum'        => array('taxable', 'shipping', 'none'),
1790
+					'context'     => array('view', 'edit'),
1791 1791
 				),
1792 1792
 				'tax_class'             => array(
1793
-					'description' => __( 'Tax class.', 'woocommerce' ),
1793
+					'description' => __('Tax class.', 'woocommerce'),
1794 1794
 					'type'        => 'string',
1795
-					'context'     => array( 'view', 'edit' ),
1795
+					'context'     => array('view', 'edit'),
1796 1796
 				),
1797 1797
 				'manage_stock'          => array(
1798
-					'description' => __( 'Stock management at product level.', 'woocommerce' ),
1798
+					'description' => __('Stock management at product level.', 'woocommerce'),
1799 1799
 					'type'        => 'boolean',
1800 1800
 					'default'     => false,
1801
-					'context'     => array( 'view', 'edit' ),
1801
+					'context'     => array('view', 'edit'),
1802 1802
 				),
1803 1803
 				'stock_quantity'        => array(
1804
-					'description' => __( 'Stock quantity.', 'woocommerce' ),
1804
+					'description' => __('Stock quantity.', 'woocommerce'),
1805 1805
 					'type'        => 'integer',
1806
-					'context'     => array( 'view', 'edit' ),
1806
+					'context'     => array('view', 'edit'),
1807 1807
 				),
1808 1808
 				'stock_status'          => array(
1809
-					'description' => __( 'Controls the stock status of the product.', 'woocommerce' ),
1809
+					'description' => __('Controls the stock status of the product.', 'woocommerce'),
1810 1810
 					'type'        => 'string',
1811 1811
 					'default'     => 'instock',
1812
-					'enum'        => array_keys( wc_get_product_stock_status_options() ),
1813
-					'context'     => array( 'view', 'edit' ),
1812
+					'enum'        => array_keys(wc_get_product_stock_status_options()),
1813
+					'context'     => array('view', 'edit'),
1814 1814
 				),
1815 1815
 				'backorders'            => array(
1816
-					'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
1816
+					'description' => __('If managing stock, this controls if backorders are allowed.', 'woocommerce'),
1817 1817
 					'type'        => 'string',
1818 1818
 					'default'     => 'no',
1819
-					'enum'        => array( 'no', 'notify', 'yes' ),
1820
-					'context'     => array( 'view', 'edit' ),
1819
+					'enum'        => array('no', 'notify', 'yes'),
1820
+					'context'     => array('view', 'edit'),
1821 1821
 				),
1822 1822
 				'backorders_allowed'    => array(
1823
-					'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
1823
+					'description' => __('Shows if backorders are allowed.', 'woocommerce'),
1824 1824
 					'type'        => 'boolean',
1825
-					'context'     => array( 'view', 'edit' ),
1825
+					'context'     => array('view', 'edit'),
1826 1826
 					'readonly'    => true,
1827 1827
 				),
1828 1828
 				'backordered'           => array(
1829
-					'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ),
1829
+					'description' => __('Shows if the product is on backordered.', 'woocommerce'),
1830 1830
 					'type'        => 'boolean',
1831
-					'context'     => array( 'view', 'edit' ),
1831
+					'context'     => array('view', 'edit'),
1832 1832
 					'readonly'    => true,
1833 1833
 				),
1834 1834
 				'sold_individually'     => array(
1835
-					'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ),
1835
+					'description' => __('Allow one item to be bought in a single order.', 'woocommerce'),
1836 1836
 					'type'        => 'boolean',
1837 1837
 					'default'     => false,
1838
-					'context'     => array( 'view', 'edit' ),
1838
+					'context'     => array('view', 'edit'),
1839 1839
 				),
1840 1840
 				'weight'                => array(
1841 1841
 					/* translators: %s: weight unit */
1842
-					'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ),
1842
+					'description' => sprintf(__('Product weight (%s).', 'woocommerce'), $weight_unit),
1843 1843
 					'type'        => 'string',
1844
-					'context'     => array( 'view', 'edit' ),
1844
+					'context'     => array('view', 'edit'),
1845 1845
 				),
1846 1846
 				'dimensions'            => array(
1847
-					'description' => __( 'Product dimensions.', 'woocommerce' ),
1847
+					'description' => __('Product dimensions.', 'woocommerce'),
1848 1848
 					'type'        => 'object',
1849
-					'context'     => array( 'view', 'edit' ),
1849
+					'context'     => array('view', 'edit'),
1850 1850
 					'properties'  => array(
1851 1851
 						'length' => array(
1852 1852
 							/* translators: %s: dimension unit */
1853
-							'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ),
1853
+							'description' => sprintf(__('Product length (%s).', 'woocommerce'), $dimension_unit),
1854 1854
 							'type'        => 'string',
1855
-							'context'     => array( 'view', 'edit' ),
1855
+							'context'     => array('view', 'edit'),
1856 1856
 						),
1857 1857
 						'width'  => array(
1858 1858
 							/* translators: %s: dimension unit */
1859
-							'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ),
1859
+							'description' => sprintf(__('Product width (%s).', 'woocommerce'), $dimension_unit),
1860 1860
 							'type'        => 'string',
1861
-							'context'     => array( 'view', 'edit' ),
1861
+							'context'     => array('view', 'edit'),
1862 1862
 						),
1863 1863
 						'height' => array(
1864 1864
 							/* translators: %s: dimension unit */
1865
-							'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ),
1865
+							'description' => sprintf(__('Product height (%s).', 'woocommerce'), $dimension_unit),
1866 1866
 							'type'        => 'string',
1867
-							'context'     => array( 'view', 'edit' ),
1867
+							'context'     => array('view', 'edit'),
1868 1868
 						),
1869 1869
 					),
1870 1870
 				),
1871 1871
 				'shipping_required'     => array(
1872
-					'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ),
1872
+					'description' => __('Shows if the product need to be shipped.', 'woocommerce'),
1873 1873
 					'type'        => 'boolean',
1874
-					'context'     => array( 'view', 'edit' ),
1874
+					'context'     => array('view', 'edit'),
1875 1875
 					'readonly'    => true,
1876 1876
 				),
1877 1877
 				'shipping_taxable'      => array(
1878
-					'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ),
1878
+					'description' => __('Shows whether or not the product shipping is taxable.', 'woocommerce'),
1879 1879
 					'type'        => 'boolean',
1880
-					'context'     => array( 'view', 'edit' ),
1880
+					'context'     => array('view', 'edit'),
1881 1881
 					'readonly'    => true,
1882 1882
 				),
1883 1883
 				'shipping_class'        => array(
1884
-					'description' => __( 'Shipping class slug.', 'woocommerce' ),
1884
+					'description' => __('Shipping class slug.', 'woocommerce'),
1885 1885
 					'type'        => 'string',
1886
-					'context'     => array( 'view', 'edit' ),
1886
+					'context'     => array('view', 'edit'),
1887 1887
 				),
1888 1888
 				'shipping_class_id'     => array(
1889
-					'description' => __( 'Shipping class ID.', 'woocommerce' ),
1889
+					'description' => __('Shipping class ID.', 'woocommerce'),
1890 1890
 					'type'        => 'string',
1891
-					'context'     => array( 'view', 'edit' ),
1891
+					'context'     => array('view', 'edit'),
1892 1892
 					'readonly'    => true,
1893 1893
 				),
1894 1894
 				'reviews_allowed'       => array(
1895
-					'description' => __( 'Allow reviews.', 'woocommerce' ),
1895
+					'description' => __('Allow reviews.', 'woocommerce'),
1896 1896
 					'type'        => 'boolean',
1897 1897
 					'default'     => true,
1898
-					'context'     => array( 'view', 'edit' ),
1898
+					'context'     => array('view', 'edit'),
1899 1899
 				),
1900 1900
 				'average_rating'        => array(
1901
-					'description' => __( 'Reviews average rating.', 'woocommerce' ),
1901
+					'description' => __('Reviews average rating.', 'woocommerce'),
1902 1902
 					'type'        => 'string',
1903
-					'context'     => array( 'view', 'edit' ),
1903
+					'context'     => array('view', 'edit'),
1904 1904
 					'readonly'    => true,
1905 1905
 				),
1906 1906
 				'rating_count'          => array(
1907
-					'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ),
1907
+					'description' => __('Amount of reviews that the product have.', 'woocommerce'),
1908 1908
 					'type'        => 'integer',
1909
-					'context'     => array( 'view', 'edit' ),
1909
+					'context'     => array('view', 'edit'),
1910 1910
 					'readonly'    => true,
1911 1911
 				),
1912 1912
 				'related_ids'           => array(
1913
-					'description' => __( 'List of related products IDs.', 'woocommerce' ),
1913
+					'description' => __('List of related products IDs.', 'woocommerce'),
1914 1914
 					'type'        => 'array',
1915 1915
 					'items'       => array(
1916 1916
 						'type' => 'integer',
1917 1917
 					),
1918
-					'context'     => array( 'view', 'edit' ),
1918
+					'context'     => array('view', 'edit'),
1919 1919
 					'readonly'    => true,
1920 1920
 				),
1921 1921
 				'upsell_ids'            => array(
1922
-					'description' => __( 'List of up-sell products IDs.', 'woocommerce' ),
1922
+					'description' => __('List of up-sell products IDs.', 'woocommerce'),
1923 1923
 					'type'        => 'array',
1924 1924
 					'items'       => array(
1925 1925
 						'type' => 'integer',
1926 1926
 					),
1927
-					'context'     => array( 'view', 'edit' ),
1927
+					'context'     => array('view', 'edit'),
1928 1928
 				),
1929 1929
 				'cross_sell_ids'        => array(
1930
-					'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ),
1930
+					'description' => __('List of cross-sell products IDs.', 'woocommerce'),
1931 1931
 					'type'        => 'array',
1932 1932
 					'items'       => array(
1933 1933
 						'type' => 'integer',
1934 1934
 					),
1935
-					'context'     => array( 'view', 'edit' ),
1935
+					'context'     => array('view', 'edit'),
1936 1936
 				),
1937 1937
 				'parent_id'             => array(
1938
-					'description' => __( 'Product parent ID.', 'woocommerce' ),
1938
+					'description' => __('Product parent ID.', 'woocommerce'),
1939 1939
 					'type'        => 'integer',
1940
-					'context'     => array( 'view', 'edit' ),
1940
+					'context'     => array('view', 'edit'),
1941 1941
 				),
1942 1942
 				'purchase_note'         => array(
1943
-					'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ),
1943
+					'description' => __('Optional note to send the customer after purchase.', 'woocommerce'),
1944 1944
 					'type'        => 'string',
1945
-					'context'     => array( 'view', 'edit' ),
1945
+					'context'     => array('view', 'edit'),
1946 1946
 				),
1947 1947
 				'categories'            => array(
1948
-					'description' => __( 'List of categories.', 'woocommerce' ),
1948
+					'description' => __('List of categories.', 'woocommerce'),
1949 1949
 					'type'        => 'array',
1950
-					'context'     => array( 'view', 'edit' ),
1950
+					'context'     => array('view', 'edit'),
1951 1951
 					'items'       => array(
1952 1952
 						'type'       => 'object',
1953 1953
 						'properties' => array(
1954 1954
 							'id'   => array(
1955
-								'description' => __( 'Category ID.', 'woocommerce' ),
1955
+								'description' => __('Category ID.', 'woocommerce'),
1956 1956
 								'type'        => 'integer',
1957
-								'context'     => array( 'view', 'edit' ),
1957
+								'context'     => array('view', 'edit'),
1958 1958
 							),
1959 1959
 							'name' => array(
1960
-								'description' => __( 'Category name.', 'woocommerce' ),
1960
+								'description' => __('Category name.', 'woocommerce'),
1961 1961
 								'type'        => 'string',
1962
-								'context'     => array( 'view', 'edit' ),
1962
+								'context'     => array('view', 'edit'),
1963 1963
 								'readonly'    => true,
1964 1964
 							),
1965 1965
 							'slug' => array(
1966
-								'description' => __( 'Category slug.', 'woocommerce' ),
1966
+								'description' => __('Category slug.', 'woocommerce'),
1967 1967
 								'type'        => 'string',
1968
-								'context'     => array( 'view', 'edit' ),
1968
+								'context'     => array('view', 'edit'),
1969 1969
 								'readonly'    => true,
1970 1970
 							),
1971 1971
 						),
1972 1972
 					),
1973 1973
 				),
1974 1974
 				'tags'                  => array(
1975
-					'description' => __( 'List of tags.', 'woocommerce' ),
1975
+					'description' => __('List of tags.', 'woocommerce'),
1976 1976
 					'type'        => 'array',
1977
-					'context'     => array( 'view', 'edit' ),
1977
+					'context'     => array('view', 'edit'),
1978 1978
 					'items'       => array(
1979 1979
 						'type'       => 'object',
1980 1980
 						'properties' => array(
1981 1981
 							'id'   => array(
1982
-								'description' => __( 'Tag ID.', 'woocommerce' ),
1982
+								'description' => __('Tag ID.', 'woocommerce'),
1983 1983
 								'type'        => 'integer',
1984
-								'context'     => array( 'view', 'edit' ),
1984
+								'context'     => array('view', 'edit'),
1985 1985
 							),
1986 1986
 							'name' => array(
1987
-								'description' => __( 'Tag name.', 'woocommerce' ),
1987
+								'description' => __('Tag name.', 'woocommerce'),
1988 1988
 								'type'        => 'string',
1989
-								'context'     => array( 'view', 'edit' ),
1989
+								'context'     => array('view', 'edit'),
1990 1990
 								'readonly'    => true,
1991 1991
 							),
1992 1992
 							'slug' => array(
1993
-								'description' => __( 'Tag slug.', 'woocommerce' ),
1993
+								'description' => __('Tag slug.', 'woocommerce'),
1994 1994
 								'type'        => 'string',
1995
-								'context'     => array( 'view', 'edit' ),
1995
+								'context'     => array('view', 'edit'),
1996 1996
 								'readonly'    => true,
1997 1997
 							),
1998 1998
 						),
1999 1999
 					),
2000 2000
 				),
2001 2001
 				'images'                => array(
2002
-					'description' => __( 'List of images.', 'woocommerce' ),
2002
+					'description' => __('List of images.', 'woocommerce'),
2003 2003
 					'type'        => 'object',
2004
-					'context'     => array( 'view', 'edit', 'embed' ),
2004
+					'context'     => array('view', 'edit', 'embed'),
2005 2005
 					'items'       => array(
2006 2006
 						'type'       => 'object',
2007 2007
 						'properties' => array(
2008 2008
 							'id'                => array(
2009
-								'description' => __( 'Image ID.', 'woocommerce' ),
2009
+								'description' => __('Image ID.', 'woocommerce'),
2010 2010
 								'type'        => 'integer',
2011
-								'context'     => array( 'view', 'edit' ),
2011
+								'context'     => array('view', 'edit'),
2012 2012
 							),
2013 2013
 							'date_created'      => array(
2014
-								'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
2014
+								'description' => __("The date the image was created, in the site's timezone.", 'woocommerce'),
2015 2015
 								'type'        => 'date-time',
2016
-								'context'     => array( 'view', 'edit' ),
2016
+								'context'     => array('view', 'edit'),
2017 2017
 								'readonly'    => true,
2018 2018
 							),
2019 2019
 							'date_created_gmt'  => array(
2020
-								'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
2020
+								'description' => __('The date the image was created, as GMT.', 'woocommerce'),
2021 2021
 								'type'        => 'date-time',
2022
-								'context'     => array( 'view', 'edit' ),
2022
+								'context'     => array('view', 'edit'),
2023 2023
 								'readonly'    => true,
2024 2024
 							),
2025 2025
 							'date_modified'     => array(
2026
-								'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
2026
+								'description' => __("The date the image was last modified, in the site's timezone.", 'woocommerce'),
2027 2027
 								'type'        => 'date-time',
2028
-								'context'     => array( 'view', 'edit' ),
2028
+								'context'     => array('view', 'edit'),
2029 2029
 								'readonly'    => true,
2030 2030
 							),
2031 2031
 							'date_modified_gmt' => array(
2032
-								'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
2032
+								'description' => __('The date the image was last modified, as GMT.', 'woocommerce'),
2033 2033
 								'type'        => 'date-time',
2034
-								'context'     => array( 'view', 'edit' ),
2034
+								'context'     => array('view', 'edit'),
2035 2035
 								'readonly'    => true,
2036 2036
 							),
2037 2037
 							'src'               => array(
2038
-								'description' => __( 'Image URL.', 'woocommerce' ),
2038
+								'description' => __('Image URL.', 'woocommerce'),
2039 2039
 								'type'        => 'string',
2040 2040
 								'format'      => 'uri',
2041
-								'context'     => array( 'view', 'edit' ),
2041
+								'context'     => array('view', 'edit'),
2042 2042
 							),
2043 2043
 							'name'              => array(
2044
-								'description' => __( 'Image name.', 'woocommerce' ),
2044
+								'description' => __('Image name.', 'woocommerce'),
2045 2045
 								'type'        => 'string',
2046
-								'context'     => array( 'view', 'edit' ),
2046
+								'context'     => array('view', 'edit'),
2047 2047
 							),
2048 2048
 							'alt'               => array(
2049
-								'description' => __( 'Image alternative text.', 'woocommerce' ),
2049
+								'description' => __('Image alternative text.', 'woocommerce'),
2050 2050
 								'type'        => 'string',
2051
-								'context'     => array( 'view', 'edit' ),
2051
+								'context'     => array('view', 'edit'),
2052 2052
 							),
2053 2053
 						),
2054 2054
 					),
2055 2055
 				),
2056 2056
 				'attributes'            => array(
2057
-					'description' => __( 'List of attributes.', 'woocommerce' ),
2057
+					'description' => __('List of attributes.', 'woocommerce'),
2058 2058
 					'type'        => 'array',
2059
-					'context'     => array( 'view', 'edit' ),
2059
+					'context'     => array('view', 'edit'),
2060 2060
 					'items'       => array(
2061 2061
 						'type'       => 'object',
2062 2062
 						'properties' => array(
2063 2063
 							'id'        => array(
2064
-								'description' => __( 'Attribute ID.', 'woocommerce' ),
2064
+								'description' => __('Attribute ID.', 'woocommerce'),
2065 2065
 								'type'        => 'integer',
2066
-								'context'     => array( 'view', 'edit' ),
2066
+								'context'     => array('view', 'edit'),
2067 2067
 							),
2068 2068
 							'name'      => array(
2069
-								'description' => __( 'Attribute name.', 'woocommerce' ),
2069
+								'description' => __('Attribute name.', 'woocommerce'),
2070 2070
 								'type'        => 'string',
2071
-								'context'     => array( 'view', 'edit' ),
2071
+								'context'     => array('view', 'edit'),
2072 2072
 							),
2073 2073
 							'position'  => array(
2074
-								'description' => __( 'Attribute position.', 'woocommerce' ),
2074
+								'description' => __('Attribute position.', 'woocommerce'),
2075 2075
 								'type'        => 'integer',
2076
-								'context'     => array( 'view', 'edit' ),
2076
+								'context'     => array('view', 'edit'),
2077 2077
 							),
2078 2078
 							'visible'   => array(
2079
-								'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ),
2079
+								'description' => __("Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce'),
2080 2080
 								'type'        => 'boolean',
2081 2081
 								'default'     => false,
2082
-								'context'     => array( 'view', 'edit' ),
2082
+								'context'     => array('view', 'edit'),
2083 2083
 							),
2084 2084
 							'variation' => array(
2085
-								'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ),
2085
+								'description' => __('Define if the attribute can be used as variation.', 'woocommerce'),
2086 2086
 								'type'        => 'boolean',
2087 2087
 								'default'     => false,
2088
-								'context'     => array( 'view', 'edit' ),
2088
+								'context'     => array('view', 'edit'),
2089 2089
 							),
2090 2090
 							'options'   => array(
2091
-								'description' => __( 'List of available term names of the attribute.', 'woocommerce' ),
2091
+								'description' => __('List of available term names of the attribute.', 'woocommerce'),
2092 2092
 								'type'        => 'array',
2093 2093
 								'items'       => array(
2094 2094
 									'type' => 'string',
2095 2095
 								),
2096
-								'context'     => array( 'view', 'edit' ),
2096
+								'context'     => array('view', 'edit'),
2097 2097
 							),
2098 2098
 						),
2099 2099
 					),
2100 2100
 				),
2101 2101
 				'default_attributes'    => array(
2102
-					'description' => __( 'Defaults variation attributes.', 'woocommerce' ),
2102
+					'description' => __('Defaults variation attributes.', 'woocommerce'),
2103 2103
 					'type'        => 'array',
2104
-					'context'     => array( 'view', 'edit' ),
2104
+					'context'     => array('view', 'edit'),
2105 2105
 					'items'       => array(
2106 2106
 						'type'       => 'object',
2107 2107
 						'properties' => array(
2108 2108
 							'id'     => array(
2109
-								'description' => __( 'Attribute ID.', 'woocommerce' ),
2109
+								'description' => __('Attribute ID.', 'woocommerce'),
2110 2110
 								'type'        => 'integer',
2111
-								'context'     => array( 'view', 'edit' ),
2111
+								'context'     => array('view', 'edit'),
2112 2112
 							),
2113 2113
 							'name'   => array(
2114
-								'description' => __( 'Attribute name.', 'woocommerce' ),
2114
+								'description' => __('Attribute name.', 'woocommerce'),
2115 2115
 								'type'        => 'string',
2116
-								'context'     => array( 'view', 'edit' ),
2116
+								'context'     => array('view', 'edit'),
2117 2117
 							),
2118 2118
 							'option' => array(
2119
-								'description' => __( 'Selected attribute term name.', 'woocommerce' ),
2119
+								'description' => __('Selected attribute term name.', 'woocommerce'),
2120 2120
 								'type'        => 'string',
2121
-								'context'     => array( 'view', 'edit' ),
2121
+								'context'     => array('view', 'edit'),
2122 2122
 							),
2123 2123
 						),
2124 2124
 					),
2125 2125
 				),
2126 2126
 				'variations'            => array(
2127
-					'description' => __( 'List of variations IDs.', 'woocommerce' ),
2127
+					'description' => __('List of variations IDs.', 'woocommerce'),
2128 2128
 					'type'        => 'array',
2129
-					'context'     => array( 'view', 'edit' ),
2129
+					'context'     => array('view', 'edit'),
2130 2130
 					'items'       => array(
2131 2131
 						'type' => 'integer',
2132 2132
 					),
2133 2133
 					'readonly'    => true,
2134 2134
 				),
2135 2135
 				'grouped_products'      => array(
2136
-					'description' => __( 'List of grouped products ID.', 'woocommerce' ),
2136
+					'description' => __('List of grouped products ID.', 'woocommerce'),
2137 2137
 					'type'        => 'array',
2138 2138
 					'items'       => array(
2139 2139
 						'type' => 'integer',
2140 2140
 					),
2141
-					'context'     => array( 'view', 'edit' ),
2141
+					'context'     => array('view', 'edit'),
2142 2142
 					'readonly'    => true,
2143 2143
 				),
2144 2144
 				'menu_order'            => array(
2145
-					'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
2145
+					'description' => __('Menu order, used to custom sort products.', 'woocommerce'),
2146 2146
 					'type'        => 'integer',
2147
-					'context'     => array( 'view', 'edit' ),
2147
+					'context'     => array('view', 'edit'),
2148 2148
 				),
2149 2149
 				'meta_data'             => array(
2150
-					'description' => __( 'Meta data.', 'woocommerce' ),
2150
+					'description' => __('Meta data.', 'woocommerce'),
2151 2151
 					'type'        => 'array',
2152
-					'context'     => array( 'view', 'edit' ),
2152
+					'context'     => array('view', 'edit'),
2153 2153
 					'items'       => array(
2154 2154
 						'type'       => 'object',
2155 2155
 						'properties' => array(
2156 2156
 							'id'    => array(
2157
-								'description' => __( 'Meta ID.', 'woocommerce' ),
2157
+								'description' => __('Meta ID.', 'woocommerce'),
2158 2158
 								'type'        => 'integer',
2159
-								'context'     => array( 'view', 'edit' ),
2159
+								'context'     => array('view', 'edit'),
2160 2160
 								'readonly'    => true,
2161 2161
 							),
2162 2162
 							'key'   => array(
2163
-								'description' => __( 'Meta key.', 'woocommerce' ),
2163
+								'description' => __('Meta key.', 'woocommerce'),
2164 2164
 								'type'        => 'string',
2165
-								'context'     => array( 'view', 'edit' ),
2165
+								'context'     => array('view', 'edit'),
2166 2166
 							),
2167 2167
 							'value' => array(
2168
-								'description' => __( 'Meta value.', 'woocommerce' ),
2168
+								'description' => __('Meta value.', 'woocommerce'),
2169 2169
 								'type'        => 'mixed',
2170
-								'context'     => array( 'view', 'edit' ),
2170
+								'context'     => array('view', 'edit'),
2171 2171
 							),
2172 2172
 						),
2173 2173
 					),
2174 2174
 				),
2175 2175
 			),
2176 2176
 		);
2177
-		return $this->add_additional_fields_schema( $schema );
2177
+		return $this->add_additional_fields_schema($schema);
2178 2178
 	}
2179 2179
 
2180 2180
 	/**
@@ -2186,130 +2186,130 @@  discard block
 block discarded – undo
2186 2186
 		$params = parent::get_collection_params();
2187 2187
 
2188 2188
 		$params['slug'] = array(
2189
-			'description'       => __( 'Limit result set to products with a specific slug.', 'woocommerce' ),
2189
+			'description'       => __('Limit result set to products with a specific slug.', 'woocommerce'),
2190 2190
 			'type'              => 'string',
2191 2191
 			'validate_callback' => 'rest_validate_request_arg',
2192 2192
 		);
2193 2193
 
2194 2194
 		$params['status'] = array(
2195 2195
 			'default'           => 'any',
2196
-			'description'       => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ),
2196
+			'description'       => __('Limit result set to products assigned a specific status.', 'woocommerce'),
2197 2197
 			'type'              => 'string',
2198
-			'enum'              => array_merge( array( 'any', 'future' ), array_keys( get_post_statuses() ) ),
2198
+			'enum'              => array_merge(array('any', 'future'), array_keys(get_post_statuses())),
2199 2199
 			'sanitize_callback' => 'sanitize_key',
2200 2200
 			'validate_callback' => 'rest_validate_request_arg',
2201 2201
 		);
2202 2202
 
2203 2203
 		$params['type'] = array(
2204
-			'description'       => __( 'Limit result set to products assigned a specific type.', 'woocommerce' ),
2204
+			'description'       => __('Limit result set to products assigned a specific type.', 'woocommerce'),
2205 2205
 			'type'              => 'string',
2206
-			'enum'              => array_keys( wc_get_product_types() ),
2206
+			'enum'              => array_keys(wc_get_product_types()),
2207 2207
 			'sanitize_callback' => 'sanitize_key',
2208 2208
 			'validate_callback' => 'rest_validate_request_arg',
2209 2209
 		);
2210 2210
 
2211 2211
 		$params['sku'] = array(
2212
-			'description'       => __( 'Limit result set to products with specific SKU(s). Use commas to separate.', 'woocommerce' ),
2212
+			'description'       => __('Limit result set to products with specific SKU(s). Use commas to separate.', 'woocommerce'),
2213 2213
 			'type'              => 'string',
2214 2214
 			'sanitize_callback' => 'sanitize_text_field',
2215 2215
 			'validate_callback' => 'rest_validate_request_arg',
2216 2216
 		);
2217 2217
 
2218 2218
 		$params['featured'] = array(
2219
-			'description'       => __( 'Limit result set to featured products.', 'woocommerce' ),
2219
+			'description'       => __('Limit result set to featured products.', 'woocommerce'),
2220 2220
 			'type'              => 'boolean',
2221 2221
 			'sanitize_callback' => 'wc_string_to_bool',
2222 2222
 			'validate_callback' => 'rest_validate_request_arg',
2223 2223
 		);
2224 2224
 
2225 2225
 		$params['category'] = array(
2226
-			'description'       => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce' ),
2226
+			'description'       => __('Limit result set to products assigned a specific category ID.', 'woocommerce'),
2227 2227
 			'type'              => 'string',
2228 2228
 			'sanitize_callback' => 'wp_parse_id_list',
2229 2229
 			'validate_callback' => 'rest_validate_request_arg',
2230 2230
 		);
2231 2231
 
2232 2232
 		$params['tag'] = array(
2233
-			'description'       => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce' ),
2233
+			'description'       => __('Limit result set to products assigned a specific tag ID.', 'woocommerce'),
2234 2234
 			'type'              => 'string',
2235 2235
 			'sanitize_callback' => 'wp_parse_id_list',
2236 2236
 			'validate_callback' => 'rest_validate_request_arg',
2237 2237
 		);
2238 2238
 
2239 2239
 		$params['shipping_class'] = array(
2240
-			'description'       => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce' ),
2240
+			'description'       => __('Limit result set to products assigned a specific shipping class ID.', 'woocommerce'),
2241 2241
 			'type'              => 'string',
2242 2242
 			'sanitize_callback' => 'wp_parse_id_list',
2243 2243
 			'validate_callback' => 'rest_validate_request_arg',
2244 2244
 		);
2245 2245
 
2246 2246
 		$params['attribute'] = array(
2247
-			'description'       => __( 'Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce' ),
2247
+			'description'       => __('Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce'),
2248 2248
 			'type'              => 'string',
2249 2249
 			'sanitize_callback' => 'sanitize_text_field',
2250 2250
 			'validate_callback' => 'rest_validate_request_arg',
2251 2251
 		);
2252 2252
 
2253 2253
 		$params['attribute_term'] = array(
2254
-			'description'       => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce' ),
2254
+			'description'       => __('Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce'),
2255 2255
 			'type'              => 'string',
2256 2256
 			'sanitize_callback' => 'wp_parse_id_list',
2257 2257
 			'validate_callback' => 'rest_validate_request_arg',
2258 2258
 		);
2259 2259
 
2260
-		if ( wc_tax_enabled() ) {
2260
+		if (wc_tax_enabled()) {
2261 2261
 			$params['tax_class'] = array(
2262
-				'description'       => __( 'Limit result set to products with a specific tax class.', 'woocommerce' ),
2262
+				'description'       => __('Limit result set to products with a specific tax class.', 'woocommerce'),
2263 2263
 				'type'              => 'string',
2264
-				'enum'              => array_merge( array( 'standard' ), \WC_Tax::get_tax_class_slugs() ),
2264
+				'enum'              => array_merge(array('standard'), \WC_Tax::get_tax_class_slugs()),
2265 2265
 				'sanitize_callback' => 'sanitize_text_field',
2266 2266
 				'validate_callback' => 'rest_validate_request_arg',
2267 2267
 			);
2268 2268
 		}
2269 2269
 
2270 2270
 		$params['on_sale'] = array(
2271
-			'description'       => __( 'Limit result set to products on sale.', 'woocommerce' ),
2271
+			'description'       => __('Limit result set to products on sale.', 'woocommerce'),
2272 2272
 			'type'              => 'boolean',
2273 2273
 			'sanitize_callback' => 'wc_string_to_bool',
2274 2274
 			'validate_callback' => 'rest_validate_request_arg',
2275 2275
 		);
2276 2276
 
2277 2277
 		$params['min_price'] = array(
2278
-			'description'       => __( 'Limit result set to products based on a minimum price.', 'woocommerce' ),
2278
+			'description'       => __('Limit result set to products based on a minimum price.', 'woocommerce'),
2279 2279
 			'type'              => 'string',
2280 2280
 			'sanitize_callback' => 'sanitize_text_field',
2281 2281
 			'validate_callback' => 'rest_validate_request_arg',
2282 2282
 		);
2283 2283
 
2284 2284
 		$params['max_price'] = array(
2285
-			'description'       => __( 'Limit result set to products based on a maximum price.', 'woocommerce' ),
2285
+			'description'       => __('Limit result set to products based on a maximum price.', 'woocommerce'),
2286 2286
 			'type'              => 'string',
2287 2287
 			'sanitize_callback' => 'sanitize_text_field',
2288 2288
 			'validate_callback' => 'rest_validate_request_arg',
2289 2289
 		);
2290 2290
 
2291 2291
 		$params['stock_status'] = array(
2292
-			'description'       => __( 'Limit result set to products with specified stock status.', 'woocommerce' ),
2292
+			'description'       => __('Limit result set to products with specified stock status.', 'woocommerce'),
2293 2293
 			'type'              => 'string',
2294
-			'enum'              => array_keys( wc_get_product_stock_status_options() ),
2294
+			'enum'              => array_keys(wc_get_product_stock_status_options()),
2295 2295
 			'sanitize_callback' => 'sanitize_text_field',
2296 2296
 			'validate_callback' => 'rest_validate_request_arg',
2297 2297
 		);
2298 2298
 
2299 2299
 		$params['low_in_stock'] = array(
2300
-			'description'       => __( 'Limit result set to products that are low or out of stock.', 'woocommerce' ),
2300
+			'description'       => __('Limit result set to products that are low or out of stock.', 'woocommerce'),
2301 2301
 			'type'              => 'boolean',
2302 2302
 			'default'           => false,
2303 2303
 			'sanitize_callback' => 'wc_string_to_bool',
2304 2304
 		);
2305 2305
 
2306 2306
 		$params['search'] = array(
2307
-			'description'       => __( 'Search by similar product name or sku.', 'woocommerce' ),
2307
+			'description'       => __('Search by similar product name or sku.', 'woocommerce'),
2308 2308
 			'type'              => 'string',
2309 2309
 			'validate_callback' => 'rest_validate_request_arg',
2310 2310
 		);
2311 2311
 
2312
-		$params['orderby']['enum'] = array_merge( $params['orderby']['enum'], array( 'price', 'popularity', 'rating' ) );
2312
+		$params['orderby']['enum'] = array_merge($params['orderby']['enum'], array('price', 'popularity', 'rating'));
2313 2313
 
2314 2314
 		return $params;
2315 2315
 	}
Please login to merge, or discard this patch.
src/Controllers/Version4/Orders.php 1 patch
Spacing   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Controllers\Version4;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 /**
15 15
  * REST API Orders controller class.
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 			array(
55 55
 				array(
56 56
 					'methods'             => \WP_REST_Server::READABLE,
57
-					'callback'            => array( $this, 'get_items' ),
58
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
+					'callback'            => array($this, 'get_items'),
58
+					'permission_callback' => array($this, 'get_items_permissions_check'),
59 59
 					'args'                => $this->get_collection_params(),
60 60
 				),
61 61
 				array(
62 62
 					'methods'             => \WP_REST_Server::CREATABLE,
63
-					'callback'            => array( $this, 'create_item' ),
64
-					'permission_callback' => array( $this, 'create_item_permissions_check' ),
65
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ),
63
+					'callback'            => array($this, 'create_item'),
64
+					'permission_callback' => array($this, 'create_item_permissions_check'),
65
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
66 66
 				),
67
-				'schema' => array( $this, 'get_public_item_schema' ),
67
+				'schema' => array($this, 'get_public_item_schema'),
68 68
 			),
69 69
 			true
70 70
 		);
@@ -75,37 +75,37 @@  discard block
 block discarded – undo
75 75
 			array(
76 76
 				'args'   => array(
77 77
 					'id' => array(
78
-						'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
78
+						'description' => __('Unique identifier for the resource.', 'woocommerce'),
79 79
 						'type'        => 'integer',
80 80
 					),
81 81
 				),
82 82
 				array(
83 83
 					'methods'             => \WP_REST_Server::READABLE,
84
-					'callback'            => array( $this, 'get_item' ),
85
-					'permission_callback' => array( $this, 'get_item_permissions_check' ),
84
+					'callback'            => array($this, 'get_item'),
85
+					'permission_callback' => array($this, 'get_item_permissions_check'),
86 86
 					'args'                => array(
87
-						'context' => $this->get_context_param( array( 'default' => 'view' ) ),
87
+						'context' => $this->get_context_param(array('default' => 'view')),
88 88
 					),
89 89
 				),
90 90
 				array(
91 91
 					'methods'             => \WP_REST_Server::EDITABLE,
92
-					'callback'            => array( $this, 'update_item' ),
93
-					'permission_callback' => array( $this, 'update_item_permissions_check' ),
94
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
92
+					'callback'            => array($this, 'update_item'),
93
+					'permission_callback' => array($this, 'update_item_permissions_check'),
94
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
95 95
 				),
96 96
 				array(
97 97
 					'methods'             => \WP_REST_Server::DELETABLE,
98
-					'callback'            => array( $this, 'delete_item' ),
99
-					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
98
+					'callback'            => array($this, 'delete_item'),
99
+					'permission_callback' => array($this, 'delete_item_permissions_check'),
100 100
 					'args'                => array(
101 101
 						'force' => array(
102 102
 							'default'     => false,
103 103
 							'type'        => 'boolean',
104
-							'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
104
+							'description' => __('Whether to bypass trash and force deletion.', 'woocommerce'),
105 105
 						),
106 106
 					),
107 107
 				),
108
-				'schema' => array( $this, 'get_public_item_schema' ),
108
+				'schema' => array($this, 'get_public_item_schema'),
109 109
 			),
110 110
 			true
111 111
 		);
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 			array(
117 117
 				array(
118 118
 					'methods'             => \WP_REST_Server::EDITABLE,
119
-					'callback'            => array( $this, 'batch_items' ),
120
-					'permission_callback' => array( $this, 'batch_items_permissions_check' ),
121
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
119
+					'callback'            => array($this, 'batch_items'),
120
+					'permission_callback' => array($this, 'batch_items_permissions_check'),
121
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
122 122
 				),
123
-				'schema' => array( $this, 'get_public_batch_schema' ),
123
+				'schema' => array($this, 'get_public_batch_schema'),
124 124
 			),
125 125
 			true
126 126
 		);
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 * @param  int $id Object ID.
134 134
 	 * @return \WC_Data|bool
135 135
 	 */
136
-	protected function get_object( $id ) {
137
-		$order = wc_get_order( $id );
136
+	protected function get_object($id) {
137
+		$order = wc_get_order($id);
138 138
 		// In case id is a refund's id (or it's not an order at all), don't expose it via /orders/ path.
139
-		if ( ! $order || 'shop_order_refund' === $order->get_type() ) {
139
+		if ( ! $order || 'shop_order_refund' === $order->get_type()) {
140 140
 			return false;
141 141
 		}
142 142
 
@@ -149,47 +149,47 @@  discard block
 block discarded – undo
149 149
 	 * @param \WC_Order_item $item Order item data.
150 150
 	 * @return array
151 151
 	 */
152
-	protected function get_order_item_data( $item ) {
152
+	protected function get_order_item_data($item) {
153 153
 		$data           = $item->get_data();
154
-		$format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' );
154
+		$format_decimal = array('subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total');
155 155
 
156 156
 		// Format decimal values.
157
-		foreach ( $format_decimal as $key ) {
158
-			if ( isset( $data[ $key ] ) ) {
159
-				$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
157
+		foreach ($format_decimal as $key) {
158
+			if (isset($data[$key])) {
159
+				$data[$key] = wc_format_decimal($data[$key], $this->request['dp']);
160 160
 			}
161 161
 		}
162 162
 
163 163
 		// Add SKU and PRICE to products.
164
-		if ( is_callable( array( $item, 'get_product' ) ) ) {
164
+		if (is_callable(array($item, 'get_product'))) {
165 165
 			$data['sku']   = $item->get_product() ? $item->get_product()->get_sku() : null;
166 166
 			$data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0;
167 167
 		}
168 168
 
169 169
 		// Format taxes.
170
-		if ( ! empty( $data['taxes']['total'] ) ) {
170
+		if ( ! empty($data['taxes']['total'])) {
171 171
 			$taxes = array();
172 172
 
173
-			foreach ( $data['taxes']['total'] as $tax_rate_id => $tax ) {
173
+			foreach ($data['taxes']['total'] as $tax_rate_id => $tax) {
174 174
 				$taxes[] = array(
175 175
 					'id'       => $tax_rate_id,
176 176
 					'total'    => $tax,
177
-					'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '',
177
+					'subtotal' => isset($data['taxes']['subtotal'][$tax_rate_id]) ? $data['taxes']['subtotal'][$tax_rate_id] : '',
178 178
 				);
179 179
 			}
180 180
 			$data['taxes'] = $taxes;
181
-		} elseif ( isset( $data['taxes'] ) ) {
181
+		} elseif (isset($data['taxes'])) {
182 182
 			$data['taxes'] = array();
183 183
 		}
184 184
 
185 185
 		// Remove names for coupons, taxes and shipping.
186
-		if ( isset( $data['code'] ) || isset( $data['rate_code'] ) || isset( $data['method_title'] ) ) {
187
-			unset( $data['name'] );
186
+		if (isset($data['code']) || isset($data['rate_code']) || isset($data['method_title'])) {
187
+			unset($data['name']);
188 188
 		}
189 189
 
190 190
 		// Remove props we don't want to expose.
191
-		unset( $data['order_id'] );
192
-		unset( $data['type'] );
191
+		unset($data['order_id']);
192
+		unset($data['type']);
193 193
 
194 194
 		return $data;
195 195
 	}
@@ -201,45 +201,45 @@  discard block
 block discarded – undo
201 201
 	 * @param  \WC_Data $object WC_Data instance.
202 202
 	 * @return array
203 203
 	 */
204
-	protected function get_formatted_item_data( $object ) {
204
+	protected function get_formatted_item_data($object) {
205 205
 		$data              = $object->get_data();
206
-		$format_decimal    = array( 'discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax' );
207
-		$format_date       = array( 'date_created', 'date_modified', 'date_completed', 'date_paid' );
208
-		$format_line_items = array( 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines' );
206
+		$format_decimal    = array('discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax');
207
+		$format_date       = array('date_created', 'date_modified', 'date_completed', 'date_paid');
208
+		$format_line_items = array('line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines');
209 209
 
210 210
 		// Format decimal values.
211
-		foreach ( $format_decimal as $key ) {
212
-			$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
211
+		foreach ($format_decimal as $key) {
212
+			$data[$key] = wc_format_decimal($data[$key], $this->request['dp']);
213 213
 		}
214 214
 
215 215
 		// Format date values.
216
-		foreach ( $format_date as $key ) {
217
-			$datetime              = $data[ $key ];
218
-			$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
219
-			$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
216
+		foreach ($format_date as $key) {
217
+			$datetime              = $data[$key];
218
+			$data[$key]          = wc_rest_prepare_date_response($datetime, false);
219
+			$data[$key . '_gmt'] = wc_rest_prepare_date_response($datetime);
220 220
 		}
221 221
 
222 222
 		// Format the order status.
223
-		$data['status'] = 'wc-' === substr( $data['status'], 0, 3 ) ? substr( $data['status'], 3 ) : $data['status'];
223
+		$data['status'] = 'wc-' === substr($data['status'], 0, 3) ? substr($data['status'], 3) : $data['status'];
224 224
 
225 225
 		// Format line items.
226
-		foreach ( $format_line_items as $key ) {
227
-			$data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) );
226
+		foreach ($format_line_items as $key) {
227
+			$data[$key] = array_values(array_map(array($this, 'get_order_item_data'), $data[$key]));
228 228
 		}
229 229
 
230 230
 		// Refunds.
231 231
 		$data['refunds'] = array();
232
-		foreach ( $object->get_refunds() as $refund ) {
232
+		foreach ($object->get_refunds() as $refund) {
233 233
 			$data['refunds'][] = array(
234 234
 				'id'     => $refund->get_id(),
235 235
 				'reason' => $refund->get_reason() ? $refund->get_reason() : '',
236
-				'total'  => '-' . wc_format_decimal( $refund->get_amount(), $this->request['dp'] ),
236
+				'total'  => '-' . wc_format_decimal($refund->get_amount(), $this->request['dp']),
237 237
 			);
238 238
 		}
239 239
 
240 240
 		// Currency symbols.
241
-		$currency_symbol         = get_woocommerce_currency_symbol( $data['currency'] );
242
-		$data['currency_symbol'] = html_entity_decode( $currency_symbol );
241
+		$currency_symbol         = get_woocommerce_currency_symbol($data['currency']);
242
+		$data['currency_symbol'] = html_entity_decode($currency_symbol);
243 243
 
244 244
 		return array(
245 245
 			'id'                   => $object->get_id(),
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 	 * @param  \WP_REST_Request $request Request object.
296 296
 	 * @return \WP_REST_Response
297 297
 	 */
298
-	public function prepare_object_for_response( $object, $request ) {
298
+	public function prepare_object_for_response($object, $request) {
299 299
 		$this->request       = $request;
300
-		$this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] );
301
-		$data                = $this->get_formatted_item_data( $object );
302
-		$context             = ! empty( $request['context'] ) ? $request['context'] : 'view';
303
-		$data                = $this->add_additional_fields_to_object( $data, $request );
304
-		$data                = $this->filter_response_by_context( $data, $context );
305
-		$response            = rest_ensure_response( $data );
306
-		$response->add_links( $this->prepare_links( $object, $request ) );
300
+		$this->request['dp'] = is_null($this->request['dp']) ? wc_get_price_decimals() : absint($this->request['dp']);
301
+		$data                = $this->get_formatted_item_data($object);
302
+		$context             = ! empty($request['context']) ? $request['context'] : 'view';
303
+		$data                = $this->add_additional_fields_to_object($data, $request);
304
+		$data                = $this->filter_response_by_context($data, $context);
305
+		$response            = rest_ensure_response($data);
306
+		$response->add_links($this->prepare_links($object, $request));
307 307
 
308 308
 		/**
309 309
 		 * Filter the data for a response.
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		 * @param \WC_Data          $object   Object data.
316 316
 		 * @param \WP_REST_Request  $request  Request object.
317 317
 		 */
318
-		return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
318
+		return apply_filters("woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request);
319 319
 	}
320 320
 
321 321
 	/**
@@ -325,25 +325,25 @@  discard block
 block discarded – undo
325 325
 	 * @param \WP_REST_Request $request Request object.
326 326
 	 * @return array                   Links for the given post.
327 327
 	 */
328
-	protected function prepare_links( $object, $request ) {
328
+	protected function prepare_links($object, $request) {
329 329
 		$links = array(
330 330
 			'self'       => array(
331
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),
331
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())),
332 332
 			),
333 333
 			'collection' => array(
334
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
334
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
335 335
 			),
336 336
 		);
337 337
 
338
-		if ( 0 !== (int) $object->get_customer_id() ) {
338
+		if (0 !== (int) $object->get_customer_id()) {
339 339
 			$links['customer'] = array(
340
-				'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object->get_customer_id() ) ),
340
+				'href' => rest_url(sprintf('/%s/customers/%d', $this->namespace, $object->get_customer_id())),
341 341
 			);
342 342
 		}
343 343
 
344
-		if ( 0 !== (int) $object->get_parent_id() ) {
344
+		if (0 !== (int) $object->get_parent_id()) {
345 345
 			$links['up'] = array(
346
-				'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ),
346
+				'href' => rest_url(sprintf('/%s/orders/%d', $this->namespace, $object->get_parent_id())),
347 347
 			);
348 348
 		}
349 349
 
@@ -357,19 +357,19 @@  discard block
 block discarded – undo
357 357
 	 * @param  \WP_REST_Request $request Full details about the request.
358 358
 	 * @return array
359 359
 	 */
360
-	protected function prepare_objects_query( $request ) {
360
+	protected function prepare_objects_query($request) {
361 361
 		global $wpdb;
362 362
 
363 363
 		// This is needed to get around an array to string notice in \WC_REST_Orders_V2_Controller::prepare_objects_query.
364 364
 		$statuses = $request['status'];
365
-		unset( $request['status'] );
366
-		$args = parent::prepare_objects_query( $request );
365
+		unset($request['status']);
366
+		$args = parent::prepare_objects_query($request);
367 367
 
368 368
 		$args['post_status'] = array();
369
-		foreach ( $statuses as $status ) {
370
-			if ( in_array( $status, $this->get_order_statuses(), true ) ) {
369
+		foreach ($statuses as $status) {
370
+			if (in_array($status, $this->get_order_statuses(), true)) {
371 371
 				$args['post_status'][] = 'wc-' . $status;
372
-			} elseif ( 'any' === $status ) {
372
+			} elseif ('any' === $status) {
373 373
 				// Set status to "any" and short-circuit out.
374 374
 				$args['post_status'] = 'any';
375 375
 				break;
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		$request['status'] = $statuses;
383 383
 
384 384
 		// Customer.
385
-		if ( isset( $request['customer'] ) ) {
386
-			if ( ! empty( $args['meta_query'] ) ) {
385
+		if (isset($request['customer'])) {
386
+			if ( ! empty($args['meta_query'])) {
387 387
 				$args['meta_query'] = array(); // WPCS: slow query ok.
388 388
 			}
389 389
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		}
396 396
 
397 397
 		// Search by product.
398
-		if ( ! empty( $request['product'] ) ) {
398
+		if ( ! empty($request['product'])) {
399 399
 			$order_ids = $wpdb->get_col(
400 400
 				$wpdb->prepare(
401 401
 					"SELECT order_id
@@ -407,25 +407,25 @@  discard block
 block discarded – undo
407 407
 			);
408 408
 
409 409
 			// Force WP_Query return empty if don't found any order.
410
-			$order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 );
410
+			$order_ids = ! empty($order_ids) ? $order_ids : array(0);
411 411
 
412 412
 			$args['post__in'] = $order_ids;
413 413
 		}
414 414
 
415 415
 		// Search.
416
-		if ( ! empty( $args['s'] ) ) {
417
-			$order_ids = wc_order_search( $args['s'] );
416
+		if ( ! empty($args['s'])) {
417
+			$order_ids = wc_order_search($args['s']);
418 418
 
419
-			if ( ! empty( $order_ids ) ) {
420
-				unset( $args['s'] );
421
-				$args['post__in'] = array_merge( $order_ids, array( 0 ) );
419
+			if ( ! empty($order_ids)) {
420
+				unset($args['s']);
421
+				$args['post__in'] = array_merge($order_ids, array(0));
422 422
 			}
423 423
 		}
424 424
 
425 425
 		// Search by partial order number.
426
-		if ( ! empty( $request['number'] ) ) {
427
-			$partial_number = trim( $request['number'] );
428
-			$limit          = intval( $args['posts_per_page'] );
426
+		if ( ! empty($request['number'])) {
427
+			$partial_number = trim($request['number']);
428
+			$limit          = intval($args['posts_per_page']);
429 429
 			$order_ids      = $wpdb->get_col(
430 430
 				$wpdb->prepare(
431 431
 					"SELECT ID
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 					WHERE post_type = 'shop_order'
434 434
 					AND ID LIKE %s
435 435
 					LIMIT %d",
436
-					$wpdb->esc_like( absint( $partial_number ) ) . '%',
436
+					$wpdb->esc_like(absint($partial_number)) . '%',
437 437
 					$limit
438 438
 				)
439 439
 			);
440 440
 
441 441
 			// Force \WP_Query return empty if don't found any order.
442
-			$order_ids        = empty( $order_ids ) ? array( 0 ) : $order_ids;
442
+			$order_ids        = empty($order_ids) ? array(0) : $order_ids;
443 443
 			$args['post__in'] = $order_ids;
444 444
 		}
445 445
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param  array $schema Schema.
453 453
 	 * @return bool
454 454
 	 */
455
-	protected function filter_writable_props( $schema ) {
456
-		return empty( $schema['readonly'] );
455
+	protected function filter_writable_props($schema) {
456
+		return empty($schema['readonly']);
457 457
 	}
458 458
 
459 459
 
@@ -465,51 +465,51 @@  discard block
 block discarded – undo
465 465
 	 * @param  bool             $creating If is creating a new object.
466 466
 	 * @return \WP_Error|WC_Data
467 467
 	 */
468
-	protected function prepare_object_for_database( $request, $creating = false ) {
469
-		$id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
470
-		$order     = new \WC_Order( $id );
468
+	protected function prepare_object_for_database($request, $creating = false) {
469
+		$id        = isset($request['id']) ? absint($request['id']) : 0;
470
+		$order     = new \WC_Order($id);
471 471
 		$schema    = $this->get_item_schema();
472
-		$data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );
472
+		$data_keys = array_keys(array_filter($schema['properties'], array($this, 'filter_writable_props')));
473 473
 
474 474
 		// Handle all writable props.
475
-		foreach ( $data_keys as $key ) {
476
-			$value = $request[ $key ];
475
+		foreach ($data_keys as $key) {
476
+			$value = $request[$key];
477 477
 
478
-			if ( ! is_null( $value ) ) {
479
-				switch ( $key ) {
478
+			if ( ! is_null($value)) {
479
+				switch ($key) {
480 480
 					case 'coupon_lines':
481 481
 					case 'status':
482 482
 						// Change should be done later so transitions have new data.
483 483
 						break;
484 484
 					case 'billing':
485 485
 					case 'shipping':
486
-						$this->update_address( $order, $value, $key );
486
+						$this->update_address($order, $value, $key);
487 487
 						break;
488 488
 					case 'line_items':
489 489
 					case 'shipping_lines':
490 490
 					case 'fee_lines':
491
-						if ( is_array( $value ) ) {
492
-							foreach ( $value as $item ) {
493
-								if ( is_array( $item ) ) {
494
-									if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) {
495
-										$order->remove_item( $item['id'] );
491
+						if (is_array($value)) {
492
+							foreach ($value as $item) {
493
+								if (is_array($item)) {
494
+									if ($this->item_is_null($item) || (isset($item['quantity']) && 0 === $item['quantity'])) {
495
+										$order->remove_item($item['id']);
496 496
 									} else {
497
-										$this->set_item( $order, $key, $item );
497
+										$this->set_item($order, $key, $item);
498 498
 									}
499 499
 								}
500 500
 							}
501 501
 						}
502 502
 						break;
503 503
 					case 'meta_data':
504
-						if ( is_array( $value ) ) {
505
-							foreach ( $value as $meta ) {
506
-								$order->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
504
+						if (is_array($value)) {
505
+							foreach ($value as $meta) {
506
+								$order->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : '');
507 507
 							}
508 508
 						}
509 509
 						break;
510 510
 					default:
511
-						if ( is_callable( array( $order, "set_{$key}" ) ) ) {
512
-							$order->{"set_{$key}"}( $value );
511
+						if (is_callable(array($order, "set_{$key}"))) {
512
+							$order->{"set_{$key}"}($value);
513 513
 						}
514 514
 						break;
515 515
 				}
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		 * @param \WP_REST_Request $request  Request object.
527 527
 		 * @param bool            $creating If is creating a new object.
528 528
 		 */
529
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating );
529
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating);
530 530
 	}
531 531
 
532 532
 	/**
@@ -537,62 +537,62 @@  discard block
 block discarded – undo
537 537
 	 * @return \WC_Data|\WP_Error
538 538
 	 * @throws \WC_REST_Exception But all errors are validated before returning any data.
539 539
 	 */
540
-	protected function save_object( $request, $creating = false ) {
540
+	protected function save_object($request, $creating = false) {
541 541
 		try {
542
-			$object = $this->prepare_object_for_database( $request, $creating );
542
+			$object = $this->prepare_object_for_database($request, $creating);
543 543
 
544
-			if ( is_wp_error( $object ) ) {
544
+			if (is_wp_error($object)) {
545 545
 				return $object;
546 546
 			}
547 547
 
548 548
 			// Make sure gateways are loaded so hooks from gateways fire on save/create.
549 549
 			WC()->payment_gateways();
550 550
 
551
-			if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] ) {
551
+			if ( ! is_null($request['customer_id']) && 0 !== $request['customer_id']) {
552 552
 				// Make sure customer exists.
553
-				if ( false === get_user_by( 'id', $request['customer_id'] ) ) {
554
-					throw new \WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 );
553
+				if (false === get_user_by('id', $request['customer_id'])) {
554
+					throw new \WC_REST_Exception('woocommerce_rest_invalid_customer_id', __('Customer ID is invalid.', 'woocommerce'), 400);
555 555
 				}
556 556
 
557 557
 				// Make sure customer is part of blog.
558
-				if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
559
-					add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
558
+				if (is_multisite() && ! is_user_member_of_blog($request['customer_id'])) {
559
+					add_user_to_blog(get_current_blog_id(), $request['customer_id'], 'customer');
560 560
 				}
561 561
 			}
562 562
 
563
-			if ( $creating ) {
564
-				$object->set_created_via( 'rest-api' );
565
-				$object->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
563
+			if ($creating) {
564
+				$object->set_created_via('rest-api');
565
+				$object->set_prices_include_tax('yes' === get_option('woocommerce_prices_include_tax'));
566 566
 				$object->calculate_totals();
567 567
 			} else {
568 568
 				// If items have changed, recalculate order totals.
569
-				if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) {
570
-					$object->calculate_totals( true );
569
+				if (isset($request['billing']) || isset($request['shipping']) || isset($request['line_items']) || isset($request['shipping_lines']) || isset($request['fee_lines']) || isset($request['coupon_lines'])) {
570
+					$object->calculate_totals(true);
571 571
 				}
572 572
 			}
573 573
 
574 574
 			// Set coupons.
575
-			$this->calculate_coupons( $request, $object );
575
+			$this->calculate_coupons($request, $object);
576 576
 
577 577
 			// Set status.
578
-			if ( ! empty( $request['status'] ) ) {
579
-				$object->set_status( $request['status'] );
578
+			if ( ! empty($request['status'])) {
579
+				$object->set_status($request['status']);
580 580
 			}
581 581
 
582 582
 			$object->save();
583 583
 
584 584
 			// Actions for after the order is saved.
585
-			if ( true === $request['set_paid'] ) {
586
-				if ( $creating || $object->needs_payment() ) {
587
-					$object->payment_complete( $request['transaction_id'] );
585
+			if (true === $request['set_paid']) {
586
+				if ($creating || $object->needs_payment()) {
587
+					$object->payment_complete($request['transaction_id']);
588 588
 				}
589 589
 			}
590 590
 
591
-			return $this->get_object( $object->get_id() );
592
-		} catch ( \WC_Data_Exception $e ) {
593
-			return new \WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
594
-		} catch ( \WC_REST_Exception $e ) {
595
-			return new \WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
591
+			return $this->get_object($object->get_id());
592
+		} catch (\WC_Data_Exception $e) {
593
+			return new \WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
594
+		} catch (\WC_REST_Exception $e) {
595
+			return new \WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
596 596
 		}
597 597
 	}
598 598
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 	 * @param array    $posted Posted data.
604 604
 	 * @param string   $type   Address type.
605 605
 	 */
606
-	protected function update_address( $order, $posted, $type = 'billing' ) {
607
-		foreach ( $posted as $key => $value ) {
608
-			if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) {
609
-				$order->{"set_{$type}_{$key}"}( $value );
606
+	protected function update_address($order, $posted, $type = 'billing') {
607
+		foreach ($posted as $key => $value) {
608
+			if (is_callable(array($order, "set_{$type}_{$key}"))) {
609
+				$order->{"set_{$type}_{$key}"}($value);
610 610
 			}
611 611
 		}
612 612
 	}
@@ -618,15 +618,15 @@  discard block
 block discarded – undo
618 618
 	 * @return int
619 619
 	 * @throws \WC_REST_Exception When SKU or ID is not valid.
620 620
 	 */
621
-	protected function get_product_id( $posted ) {
622
-		if ( ! empty( $posted['sku'] ) ) {
623
-			$product_id = (int) wc_get_product_id_by_sku( $posted['sku'] );
624
-		} elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) {
621
+	protected function get_product_id($posted) {
622
+		if ( ! empty($posted['sku'])) {
623
+			$product_id = (int) wc_get_product_id_by_sku($posted['sku']);
624
+		} elseif ( ! empty($posted['product_id']) && empty($posted['variation_id'])) {
625 625
 			$product_id = (int) $posted['product_id'];
626
-		} elseif ( ! empty( $posted['variation_id'] ) ) {
626
+		} elseif ( ! empty($posted['variation_id'])) {
627 627
 			$product_id = (int) $posted['variation_id'];
628 628
 		} else {
629
-			throw new \WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 );
629
+			throw new \WC_REST_Exception('woocommerce_rest_required_product_reference', __('Product ID or SKU is required.', 'woocommerce'), 400);
630 630
 		}
631 631
 		return $product_id;
632 632
 	}
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 	 * @param string        $prop   Order property.
639 639
 	 * @param array         $posted Request data.
640 640
 	 */
641
-	protected function maybe_set_item_prop( $item, $prop, $posted ) {
642
-		if ( isset( $posted[ $prop ] ) ) {
643
-			$item->{"set_$prop"}( $posted[ $prop ] );
641
+	protected function maybe_set_item_prop($item, $prop, $posted) {
642
+		if (isset($posted[$prop])) {
643
+			$item->{"set_$prop"}($posted[$prop]);
644 644
 		}
645 645
 	}
646 646
 
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 	 * @param string[]      $props  Properties.
652 652
 	 * @param array         $posted Request data.
653 653
 	 */
654
-	protected function maybe_set_item_props( $item, $props, $posted ) {
655
-		foreach ( $props as $prop ) {
656
-			$this->maybe_set_item_prop( $item, $prop, $posted );
654
+	protected function maybe_set_item_props($item, $props, $posted) {
655
+		foreach ($props as $prop) {
656
+			$this->maybe_set_item_prop($item, $prop, $posted);
657 657
 		}
658 658
 	}
659 659
 
@@ -663,12 +663,12 @@  discard block
 block discarded – undo
663 663
 	 * @param WC_Order_Item $item   Order item data.
664 664
 	 * @param array         $posted Request data.
665 665
 	 */
666
-	protected function maybe_set_item_meta_data( $item, $posted ) {
667
-		if ( ! empty( $posted['meta_data'] ) && is_array( $posted['meta_data'] ) ) {
668
-			foreach ( $posted['meta_data'] as $meta ) {
669
-				if ( isset( $meta['key'] ) ) {
670
-					$value = isset( $meta['value'] ) ? $meta['value'] : null;
671
-					$item->update_meta_data( $meta['key'], $value, isset( $meta['id'] ) ? $meta['id'] : '' );
666
+	protected function maybe_set_item_meta_data($item, $posted) {
667
+		if ( ! empty($posted['meta_data']) && is_array($posted['meta_data'])) {
668
+			foreach ($posted['meta_data'] as $meta) {
669
+				if (isset($meta['key'])) {
670
+					$value = isset($meta['value']) ? $meta['value'] : null;
671
+					$item->update_meta_data($meta['key'], $value, isset($meta['id']) ? $meta['id'] : '');
672 672
 				}
673 673
 			}
674 674
 		}
@@ -683,23 +683,23 @@  discard block
 block discarded – undo
683 683
 	 * @return WC_Order_Item_Product
684 684
 	 * @throws WC_REST_Exception Invalid data, server error.
685 685
 	 */
686
-	protected function prepare_line_items( $posted, $action = 'create', $item = null ) {
687
-		$item    = is_null( $item ) ? new \WC_Order_Item_Product( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item;
688
-		$product = wc_get_product( $this->get_product_id( $posted ) );
689
-
690
-		if ( $product !== $item->get_product() ) {
691
-			$item->set_product( $product );
692
-
693
-			if ( 'create' === $action ) {
694
-				$quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1;
695
-				$total    = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) );
696
-				$item->set_total( $total );
697
-				$item->set_subtotal( $total );
686
+	protected function prepare_line_items($posted, $action = 'create', $item = null) {
687
+		$item    = is_null($item) ? new \WC_Order_Item_Product( ! empty($posted['id']) ? $posted['id'] : '') : $item;
688
+		$product = wc_get_product($this->get_product_id($posted));
689
+
690
+		if ($product !== $item->get_product()) {
691
+			$item->set_product($product);
692
+
693
+			if ('create' === $action) {
694
+				$quantity = isset($posted['quantity']) ? $posted['quantity'] : 1;
695
+				$total    = wc_get_price_excluding_tax($product, array('qty' => $quantity));
696
+				$item->set_total($total);
697
+				$item->set_subtotal($total);
698 698
 			}
699 699
 		}
700 700
 
701
-		$this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted );
702
-		$this->maybe_set_item_meta_data( $item, $posted );
701
+		$this->maybe_set_item_props($item, array('name', 'quantity', 'total', 'subtotal', 'tax_class'), $posted);
702
+		$this->maybe_set_item_meta_data($item, $posted);
703 703
 
704 704
 		return $item;
705 705
 	}
@@ -713,17 +713,17 @@  discard block
 block discarded – undo
713 713
 	 * @return \WC_Order_Item_Shipping
714 714
 	 * @throws \WC_REST_Exception Invalid data, server error.
715 715
 	 */
716
-	protected function prepare_shipping_lines( $posted, $action = 'create', $item = null ) {
717
-		$item = is_null( $item ) ? new \WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item;
716
+	protected function prepare_shipping_lines($posted, $action = 'create', $item = null) {
717
+		$item = is_null($item) ? new \WC_Order_Item_Shipping( ! empty($posted['id']) ? $posted['id'] : '') : $item;
718 718
 
719
-		if ( 'create' === $action ) {
720
-			if ( empty( $posted['method_id'] ) ) {
721
-				throw new \WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 );
719
+		if ('create' === $action) {
720
+			if (empty($posted['method_id'])) {
721
+				throw new \WC_REST_Exception('woocommerce_rest_invalid_shipping_item', __('Shipping method ID is required.', 'woocommerce'), 400);
722 722
 			}
723 723
 		}
724 724
 
725
-		$this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total' ), $posted );
726
-		$this->maybe_set_item_meta_data( $item, $posted );
725
+		$this->maybe_set_item_props($item, array('method_id', 'method_title', 'total'), $posted);
726
+		$this->maybe_set_item_meta_data($item, $posted);
727 727
 
728 728
 		return $item;
729 729
 	}
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 	 * @return \WC_Order_Item_Fee
738 738
 	 * @throws \WC_REST_Exception Invalid data, server error.
739 739
 	 */
740
-	protected function prepare_fee_lines( $posted, $action = 'create', $item = null ) {
741
-		$item = is_null( $item ) ? new \WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item;
740
+	protected function prepare_fee_lines($posted, $action = 'create', $item = null) {
741
+		$item = is_null($item) ? new \WC_Order_Item_Fee( ! empty($posted['id']) ? $posted['id'] : '') : $item;
742 742
 
743
-		if ( 'create' === $action ) {
744
-			if ( empty( $posted['name'] ) ) {
745
-				throw new \WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 );
743
+		if ('create' === $action) {
744
+			if (empty($posted['name'])) {
745
+				throw new \WC_REST_Exception('woocommerce_rest_invalid_fee_item', __('Fee name is required.', 'woocommerce'), 400);
746 746
 			}
747 747
 		}
748 748
 
749
-		$this->maybe_set_item_props( $item, array( 'name', 'tax_class', 'tax_status', 'total' ), $posted );
750
-		$this->maybe_set_item_meta_data( $item, $posted );
749
+		$this->maybe_set_item_props($item, array('name', 'tax_class', 'tax_status', 'total'), $posted);
750
+		$this->maybe_set_item_meta_data($item, $posted);
751 751
 
752 752
 		return $item;
753 753
 	}
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
 	 * @return \WC_Order_Item_Coupon
762 762
 	 * @throws \WC_REST_Exception Invalid data, server error.
763 763
 	 */
764
-	protected function prepare_coupon_lines( $posted, $action = 'create', $item = null ) {
765
-		$item = is_null( $item ) ? new \WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item;
764
+	protected function prepare_coupon_lines($posted, $action = 'create', $item = null) {
765
+		$item = is_null($item) ? new \WC_Order_Item_Coupon( ! empty($posted['id']) ? $posted['id'] : '') : $item;
766 766
 
767
-		if ( 'create' === $action ) {
768
-			if ( empty( $posted['code'] ) ) {
769
-				throw new \WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
767
+		if ('create' === $action) {
768
+			if (empty($posted['code'])) {
769
+				throw new \WC_REST_Exception('woocommerce_rest_invalid_coupon_coupon', __('Coupon code is required.', 'woocommerce'), 400);
770 770
 			}
771 771
 		}
772 772
 
773
-		$this->maybe_set_item_props( $item, array( 'code', 'discount' ), $posted );
774
-		$this->maybe_set_item_meta_data( $item, $posted );
773
+		$this->maybe_set_item_props($item, array('code', 'discount'), $posted);
774
+		$this->maybe_set_item_meta_data($item, $posted);
775 775
 
776 776
 		return $item;
777 777
 	}
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 	 * @param array     $posted item provided in the request body.
787 787
 	 * @throws \WC_REST_Exception If item ID is not associated with order.
788 788
 	 */
789
-	protected function set_item( $order, $item_type, $posted ) {
789
+	protected function set_item($order, $item_type, $posted) {
790 790
 		global $wpdb;
791 791
 
792
-		if ( ! empty( $posted['id'] ) ) {
792
+		if ( ! empty($posted['id'])) {
793 793
 			$action = 'update';
794 794
 		} else {
795 795
 			$action = 'create';
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 		$item   = null;
800 800
 
801 801
 		// Verify provided line item ID is associated with order.
802
-		if ( 'update' === $action ) {
803
-			$item = $order->get_item( absint( $posted['id'] ), false );
802
+		if ('update' === $action) {
803
+			$item = $order->get_item(absint($posted['id']), false);
804 804
 
805
-			if ( ! $item ) {
806
-				throw new \WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 );
805
+			if ( ! $item) {
806
+				throw new \WC_REST_Exception('woocommerce_rest_invalid_item_id', __('Order item ID provided is not associated with order.', 'woocommerce'), 400);
807 807
 			}
808 808
 		}
809 809
 
810 810
 		// Prepare item data.
811
-		$item = $this->$method( $posted, $action, $item );
811
+		$item = $this->$method($posted, $action, $item);
812 812
 
813
-		do_action( 'woocommerce_rest_set_order_item', $item, $posted );
813
+		do_action('woocommerce_rest_set_order_item', $item, $posted);
814 814
 
815 815
 		// If creating the order, add the item to it.
816
-		if ( 'create' === $action ) {
817
-			$order->add_item( $item );
816
+		if ('create' === $action) {
817
+			$order->add_item($item);
818 818
 		} else {
819 819
 			$item->save();
820 820
 		}
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 	 * @param array $item Item provided in the request body.
828 828
 	 * @return bool True if the item resource ID is null, false otherwise.
829 829
 	 */
830
-	protected function item_is_null( $item ) {
831
-		$keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' );
830
+	protected function item_is_null($item) {
831
+		$keys = array('product_id', 'method_id', 'method_title', 'name', 'code');
832 832
 
833
-		foreach ( $keys as $key ) {
834
-			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
833
+		foreach ($keys as $key) {
834
+			if (array_key_exists($key, $item) && is_null($item[$key])) {
835 835
 				return true;
836 836
 			}
837 837
 		}
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	protected function get_order_statuses() {
848 848
 		$order_statuses = array();
849 849
 
850
-		foreach ( array_keys( wc_get_order_statuses() ) as $status ) {
851
-			$order_statuses[] = str_replace( 'wc-', '', $status );
850
+		foreach (array_keys(wc_get_order_statuses()) as $status) {
851
+			$order_statuses[] = str_replace('wc-', '', $status);
852 852
 		}
853 853
 
854 854
 		return $order_statuses;
@@ -866,543 +866,543 @@  discard block
 block discarded – undo
866 866
 			'type'       => 'object',
867 867
 			'properties' => array(
868 868
 				'id'                   => array(
869
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
869
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
870 870
 					'type'        => 'integer',
871
-					'context'     => array( 'view', 'edit' ),
871
+					'context'     => array('view', 'edit'),
872 872
 					'readonly'    => true,
873 873
 				),
874 874
 				'parent_id'            => array(
875
-					'description' => __( 'Parent order ID.', 'woocommerce' ),
875
+					'description' => __('Parent order ID.', 'woocommerce'),
876 876
 					'type'        => 'integer',
877
-					'context'     => array( 'view', 'edit' ),
877
+					'context'     => array('view', 'edit'),
878 878
 				),
879 879
 				'number'               => array(
880
-					'description' => __( 'Order number.', 'woocommerce' ),
880
+					'description' => __('Order number.', 'woocommerce'),
881 881
 					'type'        => 'string',
882
-					'context'     => array( 'view', 'edit' ),
882
+					'context'     => array('view', 'edit'),
883 883
 					'readonly'    => true,
884 884
 				),
885 885
 				'order_key'            => array(
886
-					'description' => __( 'Order key.', 'woocommerce' ),
886
+					'description' => __('Order key.', 'woocommerce'),
887 887
 					'type'        => 'string',
888
-					'context'     => array( 'view', 'edit' ),
888
+					'context'     => array('view', 'edit'),
889 889
 					'readonly'    => true,
890 890
 				),
891 891
 				'created_via'          => array(
892
-					'description' => __( 'Shows where the order was created.', 'woocommerce' ),
892
+					'description' => __('Shows where the order was created.', 'woocommerce'),
893 893
 					'type'        => 'string',
894
-					'context'     => array( 'view', 'edit' ),
894
+					'context'     => array('view', 'edit'),
895 895
 					'readonly'    => true,
896 896
 				),
897 897
 				'version'              => array(
898
-					'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ),
898
+					'description' => __('Version of WooCommerce which last updated the order.', 'woocommerce'),
899 899
 					'type'        => 'integer',
900
-					'context'     => array( 'view', 'edit' ),
900
+					'context'     => array('view', 'edit'),
901 901
 					'readonly'    => true,
902 902
 				),
903 903
 				'status'               => array(
904
-					'description' => __( 'Order status.', 'woocommerce' ),
904
+					'description' => __('Order status.', 'woocommerce'),
905 905
 					'type'        => 'string',
906 906
 					'default'     => 'pending',
907 907
 					'enum'        => $this->get_order_statuses(),
908
-					'context'     => array( 'view', 'edit' ),
908
+					'context'     => array('view', 'edit'),
909 909
 				),
910 910
 				'currency'             => array(
911
-					'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ),
911
+					'description' => __('Currency the order was created with, in ISO format.', 'woocommerce'),
912 912
 					'type'        => 'string',
913 913
 					'default'     => get_woocommerce_currency(),
914
-					'enum'        => array_keys( get_woocommerce_currencies() ),
915
-					'context'     => array( 'view', 'edit' ),
914
+					'enum'        => array_keys(get_woocommerce_currencies()),
915
+					'context'     => array('view', 'edit'),
916 916
 				),
917 917
 				'currency_symbol'      => array(
918
-					'description' => __( 'Currency symbol.', 'woocommerce' ),
918
+					'description' => __('Currency symbol.', 'woocommerce'),
919 919
 					'type'        => 'string',
920
-					'context'     => array( 'view', 'edit' ),
920
+					'context'     => array('view', 'edit'),
921 921
 					'readonly'    => true,
922 922
 				),
923 923
 				'date_created'         => array(
924
-					'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ),
924
+					'description' => __("The date the order was created, in the site's timezone.", 'woocommerce'),
925 925
 					'type'        => 'date-time',
926
-					'context'     => array( 'view', 'edit' ),
926
+					'context'     => array('view', 'edit'),
927 927
 					'readonly'    => true,
928 928
 				),
929 929
 				'date_created_gmt'     => array(
930
-					'description' => __( 'The date the order was created, as GMT.', 'woocommerce' ),
930
+					'description' => __('The date the order was created, as GMT.', 'woocommerce'),
931 931
 					'type'        => 'date-time',
932
-					'context'     => array( 'view', 'edit' ),
932
+					'context'     => array('view', 'edit'),
933 933
 					'readonly'    => true,
934 934
 				),
935 935
 				'date_modified'        => array(
936
-					'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ),
936
+					'description' => __("The date the order was last modified, in the site's timezone.", 'woocommerce'),
937 937
 					'type'        => 'date-time',
938
-					'context'     => array( 'view', 'edit' ),
938
+					'context'     => array('view', 'edit'),
939 939
 					'readonly'    => true,
940 940
 				),
941 941
 				'date_modified_gmt'    => array(
942
-					'description' => __( 'The date the order was last modified, as GMT.', 'woocommerce' ),
942
+					'description' => __('The date the order was last modified, as GMT.', 'woocommerce'),
943 943
 					'type'        => 'date-time',
944
-					'context'     => array( 'view', 'edit' ),
944
+					'context'     => array('view', 'edit'),
945 945
 					'readonly'    => true,
946 946
 				),
947 947
 				'discount_total'       => array(
948
-					'description' => __( 'Total discount amount for the order.', 'woocommerce' ),
948
+					'description' => __('Total discount amount for the order.', 'woocommerce'),
949 949
 					'type'        => 'string',
950
-					'context'     => array( 'view', 'edit' ),
950
+					'context'     => array('view', 'edit'),
951 951
 					'readonly'    => true,
952 952
 				),
953 953
 				'discount_tax'         => array(
954
-					'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ),
954
+					'description' => __('Total discount tax amount for the order.', 'woocommerce'),
955 955
 					'type'        => 'string',
956
-					'context'     => array( 'view', 'edit' ),
956
+					'context'     => array('view', 'edit'),
957 957
 					'readonly'    => true,
958 958
 				),
959 959
 				'shipping_total'       => array(
960
-					'description' => __( 'Total shipping amount for the order.', 'woocommerce' ),
960
+					'description' => __('Total shipping amount for the order.', 'woocommerce'),
961 961
 					'type'        => 'string',
962
-					'context'     => array( 'view', 'edit' ),
962
+					'context'     => array('view', 'edit'),
963 963
 					'readonly'    => true,
964 964
 				),
965 965
 				'shipping_tax'         => array(
966
-					'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ),
966
+					'description' => __('Total shipping tax amount for the order.', 'woocommerce'),
967 967
 					'type'        => 'string',
968
-					'context'     => array( 'view', 'edit' ),
968
+					'context'     => array('view', 'edit'),
969 969
 					'readonly'    => true,
970 970
 				),
971 971
 				'cart_tax'             => array(
972
-					'description' => __( 'Sum of line item taxes only.', 'woocommerce' ),
972
+					'description' => __('Sum of line item taxes only.', 'woocommerce'),
973 973
 					'type'        => 'string',
974
-					'context'     => array( 'view', 'edit' ),
974
+					'context'     => array('view', 'edit'),
975 975
 					'readonly'    => true,
976 976
 				),
977 977
 				'total'                => array(
978
-					'description' => __( 'Grand total.', 'woocommerce' ),
978
+					'description' => __('Grand total.', 'woocommerce'),
979 979
 					'type'        => 'string',
980
-					'context'     => array( 'view', 'edit' ),
980
+					'context'     => array('view', 'edit'),
981 981
 					'readonly'    => true,
982 982
 				),
983 983
 				'total_tax'            => array(
984
-					'description' => __( 'Sum of all taxes.', 'woocommerce' ),
984
+					'description' => __('Sum of all taxes.', 'woocommerce'),
985 985
 					'type'        => 'string',
986
-					'context'     => array( 'view', 'edit' ),
986
+					'context'     => array('view', 'edit'),
987 987
 					'readonly'    => true,
988 988
 				),
989 989
 				'prices_include_tax'   => array(
990
-					'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ),
990
+					'description' => __('True the prices included tax during checkout.', 'woocommerce'),
991 991
 					'type'        => 'boolean',
992
-					'context'     => array( 'view', 'edit' ),
992
+					'context'     => array('view', 'edit'),
993 993
 					'readonly'    => true,
994 994
 				),
995 995
 				'customer_id'          => array(
996
-					'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ),
996
+					'description' => __('User ID who owns the order. 0 for guests.', 'woocommerce'),
997 997
 					'type'        => 'integer',
998 998
 					'default'     => 0,
999
-					'context'     => array( 'view', 'edit' ),
999
+					'context'     => array('view', 'edit'),
1000 1000
 				),
1001 1001
 				'customer_ip_address'  => array(
1002
-					'description' => __( "Customer's IP address.", 'woocommerce' ),
1002
+					'description' => __("Customer's IP address.", 'woocommerce'),
1003 1003
 					'type'        => 'string',
1004
-					'context'     => array( 'view', 'edit' ),
1004
+					'context'     => array('view', 'edit'),
1005 1005
 					'readonly'    => true,
1006 1006
 				),
1007 1007
 				'customer_user_agent'  => array(
1008
-					'description' => __( 'User agent of the customer.', 'woocommerce' ),
1008
+					'description' => __('User agent of the customer.', 'woocommerce'),
1009 1009
 					'type'        => 'string',
1010
-					'context'     => array( 'view', 'edit' ),
1010
+					'context'     => array('view', 'edit'),
1011 1011
 					'readonly'    => true,
1012 1012
 				),
1013 1013
 				'customer_note'        => array(
1014
-					'description' => __( 'Note left by customer during checkout.', 'woocommerce' ),
1014
+					'description' => __('Note left by customer during checkout.', 'woocommerce'),
1015 1015
 					'type'        => 'string',
1016
-					'context'     => array( 'view', 'edit' ),
1016
+					'context'     => array('view', 'edit'),
1017 1017
 				),
1018 1018
 				'billing'              => array(
1019
-					'description' => __( 'Billing address.', 'woocommerce' ),
1019
+					'description' => __('Billing address.', 'woocommerce'),
1020 1020
 					'type'        => 'object',
1021
-					'context'     => array( 'view', 'edit' ),
1021
+					'context'     => array('view', 'edit'),
1022 1022
 					'properties'  => array(
1023 1023
 						'first_name' => array(
1024
-							'description' => __( 'First name.', 'woocommerce' ),
1024
+							'description' => __('First name.', 'woocommerce'),
1025 1025
 							'type'        => 'string',
1026
-							'context'     => array( 'view', 'edit' ),
1026
+							'context'     => array('view', 'edit'),
1027 1027
 						),
1028 1028
 						'last_name'  => array(
1029
-							'description' => __( 'Last name.', 'woocommerce' ),
1029
+							'description' => __('Last name.', 'woocommerce'),
1030 1030
 							'type'        => 'string',
1031
-							'context'     => array( 'view', 'edit' ),
1031
+							'context'     => array('view', 'edit'),
1032 1032
 						),
1033 1033
 						'company'    => array(
1034
-							'description' => __( 'Company name.', 'woocommerce' ),
1034
+							'description' => __('Company name.', 'woocommerce'),
1035 1035
 							'type'        => 'string',
1036
-							'context'     => array( 'view', 'edit' ),
1036
+							'context'     => array('view', 'edit'),
1037 1037
 						),
1038 1038
 						'address_1'  => array(
1039
-							'description' => __( 'Address line 1', 'woocommerce' ),
1039
+							'description' => __('Address line 1', 'woocommerce'),
1040 1040
 							'type'        => 'string',
1041
-							'context'     => array( 'view', 'edit' ),
1041
+							'context'     => array('view', 'edit'),
1042 1042
 						),
1043 1043
 						'address_2'  => array(
1044
-							'description' => __( 'Address line 2', 'woocommerce' ),
1044
+							'description' => __('Address line 2', 'woocommerce'),
1045 1045
 							'type'        => 'string',
1046
-							'context'     => array( 'view', 'edit' ),
1046
+							'context'     => array('view', 'edit'),
1047 1047
 						),
1048 1048
 						'city'       => array(
1049
-							'description' => __( 'City name.', 'woocommerce' ),
1049
+							'description' => __('City name.', 'woocommerce'),
1050 1050
 							'type'        => 'string',
1051
-							'context'     => array( 'view', 'edit' ),
1051
+							'context'     => array('view', 'edit'),
1052 1052
 						),
1053 1053
 						'state'      => array(
1054
-							'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
1054
+							'description' => __('ISO code or name of the state, province or district.', 'woocommerce'),
1055 1055
 							'type'        => 'string',
1056
-							'context'     => array( 'view', 'edit' ),
1056
+							'context'     => array('view', 'edit'),
1057 1057
 						),
1058 1058
 						'postcode'   => array(
1059
-							'description' => __( 'Postal code.', 'woocommerce' ),
1059
+							'description' => __('Postal code.', 'woocommerce'),
1060 1060
 							'type'        => 'string',
1061
-							'context'     => array( 'view', 'edit' ),
1061
+							'context'     => array('view', 'edit'),
1062 1062
 						),
1063 1063
 						'country'    => array(
1064
-							'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
1064
+							'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'),
1065 1065
 							'type'        => 'string',
1066
-							'context'     => array( 'view', 'edit' ),
1066
+							'context'     => array('view', 'edit'),
1067 1067
 						),
1068 1068
 						'email'      => array(
1069
-							'description' => __( 'Email address.', 'woocommerce' ),
1069
+							'description' => __('Email address.', 'woocommerce'),
1070 1070
 							'type'        => 'string',
1071 1071
 							'format'      => 'email',
1072
-							'context'     => array( 'view', 'edit' ),
1072
+							'context'     => array('view', 'edit'),
1073 1073
 						),
1074 1074
 						'phone'      => array(
1075
-							'description' => __( 'Phone number.', 'woocommerce' ),
1075
+							'description' => __('Phone number.', 'woocommerce'),
1076 1076
 							'type'        => 'string',
1077
-							'context'     => array( 'view', 'edit' ),
1077
+							'context'     => array('view', 'edit'),
1078 1078
 						),
1079 1079
 					),
1080 1080
 				),
1081 1081
 				'shipping'             => array(
1082
-					'description' => __( 'Shipping address.', 'woocommerce' ),
1082
+					'description' => __('Shipping address.', 'woocommerce'),
1083 1083
 					'type'        => 'object',
1084
-					'context'     => array( 'view', 'edit' ),
1084
+					'context'     => array('view', 'edit'),
1085 1085
 					'properties'  => array(
1086 1086
 						'first_name' => array(
1087
-							'description' => __( 'First name.', 'woocommerce' ),
1087
+							'description' => __('First name.', 'woocommerce'),
1088 1088
 							'type'        => 'string',
1089
-							'context'     => array( 'view', 'edit' ),
1089
+							'context'     => array('view', 'edit'),
1090 1090
 						),
1091 1091
 						'last_name'  => array(
1092
-							'description' => __( 'Last name.', 'woocommerce' ),
1092
+							'description' => __('Last name.', 'woocommerce'),
1093 1093
 							'type'        => 'string',
1094
-							'context'     => array( 'view', 'edit' ),
1094
+							'context'     => array('view', 'edit'),
1095 1095
 						),
1096 1096
 						'company'    => array(
1097
-							'description' => __( 'Company name.', 'woocommerce' ),
1097
+							'description' => __('Company name.', 'woocommerce'),
1098 1098
 							'type'        => 'string',
1099
-							'context'     => array( 'view', 'edit' ),
1099
+							'context'     => array('view', 'edit'),
1100 1100
 						),
1101 1101
 						'address_1'  => array(
1102
-							'description' => __( 'Address line 1', 'woocommerce' ),
1102
+							'description' => __('Address line 1', 'woocommerce'),
1103 1103
 							'type'        => 'string',
1104
-							'context'     => array( 'view', 'edit' ),
1104
+							'context'     => array('view', 'edit'),
1105 1105
 						),
1106 1106
 						'address_2'  => array(
1107
-							'description' => __( 'Address line 2', 'woocommerce' ),
1107
+							'description' => __('Address line 2', 'woocommerce'),
1108 1108
 							'type'        => 'string',
1109
-							'context'     => array( 'view', 'edit' ),
1109
+							'context'     => array('view', 'edit'),
1110 1110
 						),
1111 1111
 						'city'       => array(
1112
-							'description' => __( 'City name.', 'woocommerce' ),
1112
+							'description' => __('City name.', 'woocommerce'),
1113 1113
 							'type'        => 'string',
1114
-							'context'     => array( 'view', 'edit' ),
1114
+							'context'     => array('view', 'edit'),
1115 1115
 						),
1116 1116
 						'state'      => array(
1117
-							'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
1117
+							'description' => __('ISO code or name of the state, province or district.', 'woocommerce'),
1118 1118
 							'type'        => 'string',
1119
-							'context'     => array( 'view', 'edit' ),
1119
+							'context'     => array('view', 'edit'),
1120 1120
 						),
1121 1121
 						'postcode'   => array(
1122
-							'description' => __( 'Postal code.', 'woocommerce' ),
1122
+							'description' => __('Postal code.', 'woocommerce'),
1123 1123
 							'type'        => 'string',
1124
-							'context'     => array( 'view', 'edit' ),
1124
+							'context'     => array('view', 'edit'),
1125 1125
 						),
1126 1126
 						'country'    => array(
1127
-							'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
1127
+							'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'),
1128 1128
 							'type'        => 'string',
1129
-							'context'     => array( 'view', 'edit' ),
1129
+							'context'     => array('view', 'edit'),
1130 1130
 						),
1131 1131
 					),
1132 1132
 				),
1133 1133
 				'payment_method'       => array(
1134
-					'description' => __( 'Payment method ID.', 'woocommerce' ),
1134
+					'description' => __('Payment method ID.', 'woocommerce'),
1135 1135
 					'type'        => 'string',
1136
-					'context'     => array( 'view', 'edit' ),
1136
+					'context'     => array('view', 'edit'),
1137 1137
 				),
1138 1138
 				'payment_method_title' => array(
1139
-					'description' => __( 'Payment method title.', 'woocommerce' ),
1139
+					'description' => __('Payment method title.', 'woocommerce'),
1140 1140
 					'type'        => 'string',
1141
-					'context'     => array( 'view', 'edit' ),
1141
+					'context'     => array('view', 'edit'),
1142 1142
 					'arg_options' => array(
1143 1143
 						'sanitize_callback' => 'sanitize_text_field',
1144 1144
 					),
1145 1145
 				),
1146 1146
 				'transaction_id'       => array(
1147
-					'description' => __( 'Unique transaction ID.', 'woocommerce' ),
1147
+					'description' => __('Unique transaction ID.', 'woocommerce'),
1148 1148
 					'type'        => 'string',
1149
-					'context'     => array( 'view', 'edit' ),
1149
+					'context'     => array('view', 'edit'),
1150 1150
 				),
1151 1151
 				'date_paid'            => array(
1152
-					'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ),
1152
+					'description' => __("The date the order was paid, in the site's timezone.", 'woocommerce'),
1153 1153
 					'type'        => 'date-time',
1154
-					'context'     => array( 'view', 'edit' ),
1154
+					'context'     => array('view', 'edit'),
1155 1155
 					'readonly'    => true,
1156 1156
 				),
1157 1157
 				'date_paid_gmt'        => array(
1158
-					'description' => __( 'The date the order was paid, as GMT.', 'woocommerce' ),
1158
+					'description' => __('The date the order was paid, as GMT.', 'woocommerce'),
1159 1159
 					'type'        => 'date-time',
1160
-					'context'     => array( 'view', 'edit' ),
1160
+					'context'     => array('view', 'edit'),
1161 1161
 					'readonly'    => true,
1162 1162
 				),
1163 1163
 				'date_completed'       => array(
1164
-					'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
1164
+					'description' => __("The date the order was completed, in the site's timezone.", 'woocommerce'),
1165 1165
 					'type'        => 'date-time',
1166
-					'context'     => array( 'view', 'edit' ),
1166
+					'context'     => array('view', 'edit'),
1167 1167
 					'readonly'    => true,
1168 1168
 				),
1169 1169
 				'date_completed_gmt'   => array(
1170
-					'description' => __( 'The date the order was completed, as GMT.', 'woocommerce' ),
1170
+					'description' => __('The date the order was completed, as GMT.', 'woocommerce'),
1171 1171
 					'type'        => 'date-time',
1172
-					'context'     => array( 'view', 'edit' ),
1172
+					'context'     => array('view', 'edit'),
1173 1173
 					'readonly'    => true,
1174 1174
 				),
1175 1175
 				'cart_hash'            => array(
1176
-					'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
1176
+					'description' => __('MD5 hash of cart items to ensure orders are not modified.', 'woocommerce'),
1177 1177
 					'type'        => 'string',
1178
-					'context'     => array( 'view', 'edit' ),
1178
+					'context'     => array('view', 'edit'),
1179 1179
 					'readonly'    => true,
1180 1180
 				),
1181 1181
 				'meta_data'            => array(
1182
-					'description' => __( 'Meta data.', 'woocommerce' ),
1182
+					'description' => __('Meta data.', 'woocommerce'),
1183 1183
 					'type'        => 'array',
1184
-					'context'     => array( 'view', 'edit' ),
1184
+					'context'     => array('view', 'edit'),
1185 1185
 					'items'       => array(
1186 1186
 						'type'       => 'object',
1187 1187
 						'properties' => array(
1188 1188
 							'id'    => array(
1189
-								'description' => __( 'Meta ID.', 'woocommerce' ),
1189
+								'description' => __('Meta ID.', 'woocommerce'),
1190 1190
 								'type'        => 'integer',
1191
-								'context'     => array( 'view', 'edit' ),
1191
+								'context'     => array('view', 'edit'),
1192 1192
 								'readonly'    => true,
1193 1193
 							),
1194 1194
 							'key'   => array(
1195
-								'description' => __( 'Meta key.', 'woocommerce' ),
1195
+								'description' => __('Meta key.', 'woocommerce'),
1196 1196
 								'type'        => 'string',
1197
-								'context'     => array( 'view', 'edit' ),
1197
+								'context'     => array('view', 'edit'),
1198 1198
 							),
1199 1199
 							'value' => array(
1200
-								'description' => __( 'Meta value.', 'woocommerce' ),
1200
+								'description' => __('Meta value.', 'woocommerce'),
1201 1201
 								'type'        => 'mixed',
1202
-								'context'     => array( 'view', 'edit' ),
1202
+								'context'     => array('view', 'edit'),
1203 1203
 							),
1204 1204
 						),
1205 1205
 					),
1206 1206
 				),
1207 1207
 				'line_items'           => array(
1208
-					'description' => __( 'Line items data.', 'woocommerce' ),
1208
+					'description' => __('Line items data.', 'woocommerce'),
1209 1209
 					'type'        => 'array',
1210
-					'context'     => array( 'view', 'edit' ),
1210
+					'context'     => array('view', 'edit'),
1211 1211
 					'items'       => array(
1212 1212
 						'type'       => 'object',
1213 1213
 						'properties' => array(
1214 1214
 							'id'           => array(
1215
-								'description' => __( 'Item ID.', 'woocommerce' ),
1215
+								'description' => __('Item ID.', 'woocommerce'),
1216 1216
 								'type'        => 'integer',
1217
-								'context'     => array( 'view', 'edit' ),
1217
+								'context'     => array('view', 'edit'),
1218 1218
 								'readonly'    => true,
1219 1219
 							),
1220 1220
 							'name'         => array(
1221
-								'description' => __( 'Product name.', 'woocommerce' ),
1221
+								'description' => __('Product name.', 'woocommerce'),
1222 1222
 								'type'        => 'mixed',
1223
-								'context'     => array( 'view', 'edit' ),
1223
+								'context'     => array('view', 'edit'),
1224 1224
 							),
1225 1225
 							'product_id'   => array(
1226
-								'description' => __( 'Product ID.', 'woocommerce' ),
1226
+								'description' => __('Product ID.', 'woocommerce'),
1227 1227
 								'type'        => 'mixed',
1228
-								'context'     => array( 'view', 'edit' ),
1228
+								'context'     => array('view', 'edit'),
1229 1229
 							),
1230 1230
 							'variation_id' => array(
1231
-								'description' => __( 'Variation ID, if applicable.', 'woocommerce' ),
1231
+								'description' => __('Variation ID, if applicable.', 'woocommerce'),
1232 1232
 								'type'        => 'integer',
1233
-								'context'     => array( 'view', 'edit' ),
1233
+								'context'     => array('view', 'edit'),
1234 1234
 							),
1235 1235
 							'quantity'     => array(
1236
-								'description' => __( 'Quantity ordered.', 'woocommerce' ),
1236
+								'description' => __('Quantity ordered.', 'woocommerce'),
1237 1237
 								'type'        => 'integer',
1238
-								'context'     => array( 'view', 'edit' ),
1238
+								'context'     => array('view', 'edit'),
1239 1239
 							),
1240 1240
 							'tax_class'    => array(
1241
-								'description' => __( 'Tax class of product.', 'woocommerce' ),
1241
+								'description' => __('Tax class of product.', 'woocommerce'),
1242 1242
 								'type'        => 'string',
1243
-								'context'     => array( 'view', 'edit' ),
1243
+								'context'     => array('view', 'edit'),
1244 1244
 							),
1245 1245
 							'subtotal'     => array(
1246
-								'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
1246
+								'description' => __('Line subtotal (before discounts).', 'woocommerce'),
1247 1247
 								'type'        => 'string',
1248
-								'context'     => array( 'view', 'edit' ),
1248
+								'context'     => array('view', 'edit'),
1249 1249
 							),
1250 1250
 							'subtotal_tax' => array(
1251
-								'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
1251
+								'description' => __('Line subtotal tax (before discounts).', 'woocommerce'),
1252 1252
 								'type'        => 'string',
1253
-								'context'     => array( 'view', 'edit' ),
1253
+								'context'     => array('view', 'edit'),
1254 1254
 								'readonly'    => true,
1255 1255
 							),
1256 1256
 							'total'        => array(
1257
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1257
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1258 1258
 								'type'        => 'string',
1259
-								'context'     => array( 'view', 'edit' ),
1259
+								'context'     => array('view', 'edit'),
1260 1260
 							),
1261 1261
 							'total_tax'    => array(
1262
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1262
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1263 1263
 								'type'        => 'string',
1264
-								'context'     => array( 'view', 'edit' ),
1264
+								'context'     => array('view', 'edit'),
1265 1265
 								'readonly'    => true,
1266 1266
 							),
1267 1267
 							'taxes'        => array(
1268
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1268
+								'description' => __('Line taxes.', 'woocommerce'),
1269 1269
 								'type'        => 'array',
1270
-								'context'     => array( 'view', 'edit' ),
1270
+								'context'     => array('view', 'edit'),
1271 1271
 								'readonly'    => true,
1272 1272
 								'items'       => array(
1273 1273
 									'type'       => 'object',
1274 1274
 									'properties' => array(
1275 1275
 										'id'       => array(
1276
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1276
+											'description' => __('Tax rate ID.', 'woocommerce'),
1277 1277
 											'type'        => 'integer',
1278
-											'context'     => array( 'view', 'edit' ),
1278
+											'context'     => array('view', 'edit'),
1279 1279
 										),
1280 1280
 										'total'    => array(
1281
-											'description' => __( 'Tax total.', 'woocommerce' ),
1281
+											'description' => __('Tax total.', 'woocommerce'),
1282 1282
 											'type'        => 'string',
1283
-											'context'     => array( 'view', 'edit' ),
1283
+											'context'     => array('view', 'edit'),
1284 1284
 										),
1285 1285
 										'subtotal' => array(
1286
-											'description' => __( 'Tax subtotal.', 'woocommerce' ),
1286
+											'description' => __('Tax subtotal.', 'woocommerce'),
1287 1287
 											'type'        => 'string',
1288
-											'context'     => array( 'view', 'edit' ),
1288
+											'context'     => array('view', 'edit'),
1289 1289
 										),
1290 1290
 									),
1291 1291
 								),
1292 1292
 							),
1293 1293
 							'meta_data'    => array(
1294
-								'description' => __( 'Meta data.', 'woocommerce' ),
1294
+								'description' => __('Meta data.', 'woocommerce'),
1295 1295
 								'type'        => 'array',
1296
-								'context'     => array( 'view', 'edit' ),
1296
+								'context'     => array('view', 'edit'),
1297 1297
 								'items'       => array(
1298 1298
 									'type'       => 'object',
1299 1299
 									'properties' => array(
1300 1300
 										'id'    => array(
1301
-											'description' => __( 'Meta ID.', 'woocommerce' ),
1301
+											'description' => __('Meta ID.', 'woocommerce'),
1302 1302
 											'type'        => 'integer',
1303
-											'context'     => array( 'view', 'edit' ),
1303
+											'context'     => array('view', 'edit'),
1304 1304
 											'readonly'    => true,
1305 1305
 										),
1306 1306
 										'key'   => array(
1307
-											'description' => __( 'Meta key.', 'woocommerce' ),
1307
+											'description' => __('Meta key.', 'woocommerce'),
1308 1308
 											'type'        => 'string',
1309
-											'context'     => array( 'view', 'edit' ),
1309
+											'context'     => array('view', 'edit'),
1310 1310
 										),
1311 1311
 										'value' => array(
1312
-											'description' => __( 'Meta value.', 'woocommerce' ),
1312
+											'description' => __('Meta value.', 'woocommerce'),
1313 1313
 											'type'        => 'mixed',
1314
-											'context'     => array( 'view', 'edit' ),
1314
+											'context'     => array('view', 'edit'),
1315 1315
 										),
1316 1316
 									),
1317 1317
 								),
1318 1318
 							),
1319 1319
 							'sku'          => array(
1320
-								'description' => __( 'Product SKU.', 'woocommerce' ),
1320
+								'description' => __('Product SKU.', 'woocommerce'),
1321 1321
 								'type'        => 'string',
1322
-								'context'     => array( 'view', 'edit' ),
1322
+								'context'     => array('view', 'edit'),
1323 1323
 								'readonly'    => true,
1324 1324
 							),
1325 1325
 							'price'        => array(
1326
-								'description' => __( 'Product price.', 'woocommerce' ),
1326
+								'description' => __('Product price.', 'woocommerce'),
1327 1327
 								'type'        => 'number',
1328
-								'context'     => array( 'view', 'edit' ),
1328
+								'context'     => array('view', 'edit'),
1329 1329
 								'readonly'    => true,
1330 1330
 							),
1331 1331
 						),
1332 1332
 					),
1333 1333
 				),
1334 1334
 				'tax_lines'            => array(
1335
-					'description' => __( 'Tax lines data.', 'woocommerce' ),
1335
+					'description' => __('Tax lines data.', 'woocommerce'),
1336 1336
 					'type'        => 'array',
1337
-					'context'     => array( 'view', 'edit' ),
1337
+					'context'     => array('view', 'edit'),
1338 1338
 					'readonly'    => true,
1339 1339
 					'items'       => array(
1340 1340
 						'type'       => 'object',
1341 1341
 						'properties' => array(
1342 1342
 							'id'                 => array(
1343
-								'description' => __( 'Item ID.', 'woocommerce' ),
1343
+								'description' => __('Item ID.', 'woocommerce'),
1344 1344
 								'type'        => 'integer',
1345
-								'context'     => array( 'view', 'edit' ),
1345
+								'context'     => array('view', 'edit'),
1346 1346
 								'readonly'    => true,
1347 1347
 							),
1348 1348
 							'rate_code'          => array(
1349
-								'description' => __( 'Tax rate code.', 'woocommerce' ),
1349
+								'description' => __('Tax rate code.', 'woocommerce'),
1350 1350
 								'type'        => 'string',
1351
-								'context'     => array( 'view', 'edit' ),
1351
+								'context'     => array('view', 'edit'),
1352 1352
 								'readonly'    => true,
1353 1353
 							),
1354 1354
 							'rate_id'            => array(
1355
-								'description' => __( 'Tax rate ID.', 'woocommerce' ),
1355
+								'description' => __('Tax rate ID.', 'woocommerce'),
1356 1356
 								'type'        => 'string',
1357
-								'context'     => array( 'view', 'edit' ),
1357
+								'context'     => array('view', 'edit'),
1358 1358
 								'readonly'    => true,
1359 1359
 							),
1360 1360
 							'label'              => array(
1361
-								'description' => __( 'Tax rate label.', 'woocommerce' ),
1361
+								'description' => __('Tax rate label.', 'woocommerce'),
1362 1362
 								'type'        => 'string',
1363
-								'context'     => array( 'view', 'edit' ),
1363
+								'context'     => array('view', 'edit'),
1364 1364
 								'readonly'    => true,
1365 1365
 							),
1366 1366
 							'compound'           => array(
1367
-								'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ),
1367
+								'description' => __('Show if is a compound tax rate.', 'woocommerce'),
1368 1368
 								'type'        => 'boolean',
1369
-								'context'     => array( 'view', 'edit' ),
1369
+								'context'     => array('view', 'edit'),
1370 1370
 								'readonly'    => true,
1371 1371
 							),
1372 1372
 							'tax_total'          => array(
1373
-								'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ),
1373
+								'description' => __('Tax total (not including shipping taxes).', 'woocommerce'),
1374 1374
 								'type'        => 'string',
1375
-								'context'     => array( 'view', 'edit' ),
1375
+								'context'     => array('view', 'edit'),
1376 1376
 								'readonly'    => true,
1377 1377
 							),
1378 1378
 							'shipping_tax_total' => array(
1379
-								'description' => __( 'Shipping tax total.', 'woocommerce' ),
1379
+								'description' => __('Shipping tax total.', 'woocommerce'),
1380 1380
 								'type'        => 'string',
1381
-								'context'     => array( 'view', 'edit' ),
1381
+								'context'     => array('view', 'edit'),
1382 1382
 								'readonly'    => true,
1383 1383
 							),
1384 1384
 							'meta_data'          => array(
1385
-								'description' => __( 'Meta data.', 'woocommerce' ),
1385
+								'description' => __('Meta data.', 'woocommerce'),
1386 1386
 								'type'        => 'array',
1387
-								'context'     => array( 'view', 'edit' ),
1387
+								'context'     => array('view', 'edit'),
1388 1388
 								'items'       => array(
1389 1389
 									'type'       => 'object',
1390 1390
 									'properties' => array(
1391 1391
 										'id'    => array(
1392
-											'description' => __( 'Meta ID.', 'woocommerce' ),
1392
+											'description' => __('Meta ID.', 'woocommerce'),
1393 1393
 											'type'        => 'integer',
1394
-											'context'     => array( 'view', 'edit' ),
1394
+											'context'     => array('view', 'edit'),
1395 1395
 											'readonly'    => true,
1396 1396
 										),
1397 1397
 										'key'   => array(
1398
-											'description' => __( 'Meta key.', 'woocommerce' ),
1398
+											'description' => __('Meta key.', 'woocommerce'),
1399 1399
 											'type'        => 'string',
1400
-											'context'     => array( 'view', 'edit' ),
1400
+											'context'     => array('view', 'edit'),
1401 1401
 										),
1402 1402
 										'value' => array(
1403
-											'description' => __( 'Meta value.', 'woocommerce' ),
1403
+											'description' => __('Meta value.', 'woocommerce'),
1404 1404
 											'type'        => 'mixed',
1405
-											'context'     => array( 'view', 'edit' ),
1405
+											'context'     => array('view', 'edit'),
1406 1406
 										),
1407 1407
 									),
1408 1408
 								),
@@ -1411,89 +1411,89 @@  discard block
 block discarded – undo
1411 1411
 					),
1412 1412
 				),
1413 1413
 				'shipping_lines'       => array(
1414
-					'description' => __( 'Shipping lines data.', 'woocommerce' ),
1414
+					'description' => __('Shipping lines data.', 'woocommerce'),
1415 1415
 					'type'        => 'array',
1416
-					'context'     => array( 'view', 'edit' ),
1416
+					'context'     => array('view', 'edit'),
1417 1417
 					'items'       => array(
1418 1418
 						'type'       => 'object',
1419 1419
 						'properties' => array(
1420 1420
 							'id'           => array(
1421
-								'description' => __( 'Item ID.', 'woocommerce' ),
1421
+								'description' => __('Item ID.', 'woocommerce'),
1422 1422
 								'type'        => 'integer',
1423
-								'context'     => array( 'view', 'edit' ),
1423
+								'context'     => array('view', 'edit'),
1424 1424
 								'readonly'    => true,
1425 1425
 							),
1426 1426
 							'method_title' => array(
1427
-								'description' => __( 'Shipping method name.', 'woocommerce' ),
1427
+								'description' => __('Shipping method name.', 'woocommerce'),
1428 1428
 								'type'        => 'mixed',
1429
-								'context'     => array( 'view', 'edit' ),
1429
+								'context'     => array('view', 'edit'),
1430 1430
 							),
1431 1431
 							'method_id'    => array(
1432
-								'description' => __( 'Shipping method ID.', 'woocommerce' ),
1432
+								'description' => __('Shipping method ID.', 'woocommerce'),
1433 1433
 								'type'        => 'mixed',
1434
-								'context'     => array( 'view', 'edit' ),
1434
+								'context'     => array('view', 'edit'),
1435 1435
 							),
1436 1436
 							'instance_id'  => array(
1437
-								'description' => __( 'Shipping instance ID.', 'woocommerce' ),
1437
+								'description' => __('Shipping instance ID.', 'woocommerce'),
1438 1438
 								'type'        => 'string',
1439
-								'context'     => array( 'view', 'edit' ),
1439
+								'context'     => array('view', 'edit'),
1440 1440
 							),
1441 1441
 							'total'        => array(
1442
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1442
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1443 1443
 								'type'        => 'string',
1444
-								'context'     => array( 'view', 'edit' ),
1444
+								'context'     => array('view', 'edit'),
1445 1445
 							),
1446 1446
 							'total_tax'    => array(
1447
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1447
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1448 1448
 								'type'        => 'string',
1449
-								'context'     => array( 'view', 'edit' ),
1449
+								'context'     => array('view', 'edit'),
1450 1450
 								'readonly'    => true,
1451 1451
 							),
1452 1452
 							'taxes'        => array(
1453
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1453
+								'description' => __('Line taxes.', 'woocommerce'),
1454 1454
 								'type'        => 'array',
1455
-								'context'     => array( 'view', 'edit' ),
1455
+								'context'     => array('view', 'edit'),
1456 1456
 								'readonly'    => true,
1457 1457
 								'items'       => array(
1458 1458
 									'type'       => 'object',
1459 1459
 									'properties' => array(
1460 1460
 										'id'    => array(
1461
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1461
+											'description' => __('Tax rate ID.', 'woocommerce'),
1462 1462
 											'type'        => 'integer',
1463
-											'context'     => array( 'view', 'edit' ),
1463
+											'context'     => array('view', 'edit'),
1464 1464
 											'readonly'    => true,
1465 1465
 										),
1466 1466
 										'total' => array(
1467
-											'description' => __( 'Tax total.', 'woocommerce' ),
1467
+											'description' => __('Tax total.', 'woocommerce'),
1468 1468
 											'type'        => 'string',
1469
-											'context'     => array( 'view', 'edit' ),
1469
+											'context'     => array('view', 'edit'),
1470 1470
 											'readonly'    => true,
1471 1471
 										),
1472 1472
 									),
1473 1473
 								),
1474 1474
 							),
1475 1475
 							'meta_data'    => array(
1476
-								'description' => __( 'Meta data.', 'woocommerce' ),
1476
+								'description' => __('Meta data.', 'woocommerce'),
1477 1477
 								'type'        => 'array',
1478
-								'context'     => array( 'view', 'edit' ),
1478
+								'context'     => array('view', 'edit'),
1479 1479
 								'items'       => array(
1480 1480
 									'type'       => 'object',
1481 1481
 									'properties' => array(
1482 1482
 										'id'    => array(
1483
-											'description' => __( 'Meta ID.', 'woocommerce' ),
1483
+											'description' => __('Meta ID.', 'woocommerce'),
1484 1484
 											'type'        => 'integer',
1485
-											'context'     => array( 'view', 'edit' ),
1485
+											'context'     => array('view', 'edit'),
1486 1486
 											'readonly'    => true,
1487 1487
 										),
1488 1488
 										'key'   => array(
1489
-											'description' => __( 'Meta key.', 'woocommerce' ),
1489
+											'description' => __('Meta key.', 'woocommerce'),
1490 1490
 											'type'        => 'string',
1491
-											'context'     => array( 'view', 'edit' ),
1491
+											'context'     => array('view', 'edit'),
1492 1492
 										),
1493 1493
 										'value' => array(
1494
-											'description' => __( 'Meta value.', 'woocommerce' ),
1494
+											'description' => __('Meta value.', 'woocommerce'),
1495 1495
 											'type'        => 'mixed',
1496
-											'context'     => array( 'view', 'edit' ),
1496
+											'context'     => array('view', 'edit'),
1497 1497
 										),
1498 1498
 									),
1499 1499
 								),
@@ -1502,96 +1502,96 @@  discard block
 block discarded – undo
1502 1502
 					),
1503 1503
 				),
1504 1504
 				'fee_lines'            => array(
1505
-					'description' => __( 'Fee lines data.', 'woocommerce' ),
1505
+					'description' => __('Fee lines data.', 'woocommerce'),
1506 1506
 					'type'        => 'array',
1507
-					'context'     => array( 'view', 'edit' ),
1507
+					'context'     => array('view', 'edit'),
1508 1508
 					'items'       => array(
1509 1509
 						'type'       => 'object',
1510 1510
 						'properties' => array(
1511 1511
 							'id'         => array(
1512
-								'description' => __( 'Item ID.', 'woocommerce' ),
1512
+								'description' => __('Item ID.', 'woocommerce'),
1513 1513
 								'type'        => 'integer',
1514
-								'context'     => array( 'view', 'edit' ),
1514
+								'context'     => array('view', 'edit'),
1515 1515
 								'readonly'    => true,
1516 1516
 							),
1517 1517
 							'name'       => array(
1518
-								'description' => __( 'Fee name.', 'woocommerce' ),
1518
+								'description' => __('Fee name.', 'woocommerce'),
1519 1519
 								'type'        => 'mixed',
1520
-								'context'     => array( 'view', 'edit' ),
1520
+								'context'     => array('view', 'edit'),
1521 1521
 							),
1522 1522
 							'tax_class'  => array(
1523
-								'description' => __( 'Tax class of fee.', 'woocommerce' ),
1523
+								'description' => __('Tax class of fee.', 'woocommerce'),
1524 1524
 								'type'        => 'string',
1525
-								'context'     => array( 'view', 'edit' ),
1525
+								'context'     => array('view', 'edit'),
1526 1526
 							),
1527 1527
 							'tax_status' => array(
1528
-								'description' => __( 'Tax status of fee.', 'woocommerce' ),
1528
+								'description' => __('Tax status of fee.', 'woocommerce'),
1529 1529
 								'type'        => 'string',
1530
-								'context'     => array( 'view', 'edit' ),
1531
-								'enum'        => array( 'taxable', 'none' ),
1530
+								'context'     => array('view', 'edit'),
1531
+								'enum'        => array('taxable', 'none'),
1532 1532
 							),
1533 1533
 							'total'      => array(
1534
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1534
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1535 1535
 								'type'        => 'string',
1536
-								'context'     => array( 'view', 'edit' ),
1536
+								'context'     => array('view', 'edit'),
1537 1537
 							),
1538 1538
 							'total_tax'  => array(
1539
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1539
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1540 1540
 								'type'        => 'string',
1541
-								'context'     => array( 'view', 'edit' ),
1541
+								'context'     => array('view', 'edit'),
1542 1542
 								'readonly'    => true,
1543 1543
 							),
1544 1544
 							'taxes'      => array(
1545
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1545
+								'description' => __('Line taxes.', 'woocommerce'),
1546 1546
 								'type'        => 'array',
1547
-								'context'     => array( 'view', 'edit' ),
1547
+								'context'     => array('view', 'edit'),
1548 1548
 								'readonly'    => true,
1549 1549
 								'items'       => array(
1550 1550
 									'type'       => 'object',
1551 1551
 									'properties' => array(
1552 1552
 										'id'       => array(
1553
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1553
+											'description' => __('Tax rate ID.', 'woocommerce'),
1554 1554
 											'type'        => 'integer',
1555
-											'context'     => array( 'view', 'edit' ),
1555
+											'context'     => array('view', 'edit'),
1556 1556
 											'readonly'    => true,
1557 1557
 										),
1558 1558
 										'total'    => array(
1559
-											'description' => __( 'Tax total.', 'woocommerce' ),
1559
+											'description' => __('Tax total.', 'woocommerce'),
1560 1560
 											'type'        => 'string',
1561
-											'context'     => array( 'view', 'edit' ),
1561
+											'context'     => array('view', 'edit'),
1562 1562
 											'readonly'    => true,
1563 1563
 										),
1564 1564
 										'subtotal' => array(
1565
-											'description' => __( 'Tax subtotal.', 'woocommerce' ),
1565
+											'description' => __('Tax subtotal.', 'woocommerce'),
1566 1566
 											'type'        => 'string',
1567
-											'context'     => array( 'view', 'edit' ),
1567
+											'context'     => array('view', 'edit'),
1568 1568
 											'readonly'    => true,
1569 1569
 										),
1570 1570
 									),
1571 1571
 								),
1572 1572
 							),
1573 1573
 							'meta_data'  => array(
1574
-								'description' => __( 'Meta data.', 'woocommerce' ),
1574
+								'description' => __('Meta data.', 'woocommerce'),
1575 1575
 								'type'        => 'array',
1576
-								'context'     => array( 'view', 'edit' ),
1576
+								'context'     => array('view', 'edit'),
1577 1577
 								'items'       => array(
1578 1578
 									'type'       => 'object',
1579 1579
 									'properties' => array(
1580 1580
 										'id'    => array(
1581
-											'description' => __( 'Meta ID.', 'woocommerce' ),
1581
+											'description' => __('Meta ID.', 'woocommerce'),
1582 1582
 											'type'        => 'integer',
1583
-											'context'     => array( 'view', 'edit' ),
1583
+											'context'     => array('view', 'edit'),
1584 1584
 											'readonly'    => true,
1585 1585
 										),
1586 1586
 										'key'   => array(
1587
-											'description' => __( 'Meta key.', 'woocommerce' ),
1587
+											'description' => __('Meta key.', 'woocommerce'),
1588 1588
 											'type'        => 'string',
1589
-											'context'     => array( 'view', 'edit' ),
1589
+											'context'     => array('view', 'edit'),
1590 1590
 										),
1591 1591
 										'value' => array(
1592
-											'description' => __( 'Meta value.', 'woocommerce' ),
1592
+											'description' => __('Meta value.', 'woocommerce'),
1593 1593
 											'type'        => 'mixed',
1594
-											'context'     => array( 'view', 'edit' ),
1594
+											'context'     => array('view', 'edit'),
1595 1595
 										),
1596 1596
 									),
1597 1597
 								),
@@ -1600,57 +1600,57 @@  discard block
 block discarded – undo
1600 1600
 					),
1601 1601
 				),
1602 1602
 				'coupon_lines'         => array(
1603
-					'description' => __( 'Coupons line data.', 'woocommerce' ),
1603
+					'description' => __('Coupons line data.', 'woocommerce'),
1604 1604
 					'type'        => 'array',
1605
-					'context'     => array( 'view', 'edit' ),
1605
+					'context'     => array('view', 'edit'),
1606 1606
 					'items'       => array(
1607 1607
 						'type'       => 'object',
1608 1608
 						'properties' => array(
1609 1609
 							'id'           => array(
1610
-								'description' => __( 'Item ID.', 'woocommerce' ),
1610
+								'description' => __('Item ID.', 'woocommerce'),
1611 1611
 								'type'        => 'integer',
1612
-								'context'     => array( 'view', 'edit' ),
1612
+								'context'     => array('view', 'edit'),
1613 1613
 								'readonly'    => true,
1614 1614
 							),
1615 1615
 							'code'         => array(
1616
-								'description' => __( 'Coupon code.', 'woocommerce' ),
1616
+								'description' => __('Coupon code.', 'woocommerce'),
1617 1617
 								'type'        => 'mixed',
1618
-								'context'     => array( 'view', 'edit' ),
1618
+								'context'     => array('view', 'edit'),
1619 1619
 							),
1620 1620
 							'discount'     => array(
1621
-								'description' => __( 'Discount total.', 'woocommerce' ),
1621
+								'description' => __('Discount total.', 'woocommerce'),
1622 1622
 								'type'        => 'string',
1623
-								'context'     => array( 'view', 'edit' ),
1623
+								'context'     => array('view', 'edit'),
1624 1624
 								'readonly'    => true,
1625 1625
 							),
1626 1626
 							'discount_tax' => array(
1627
-								'description' => __( 'Discount total tax.', 'woocommerce' ),
1627
+								'description' => __('Discount total tax.', 'woocommerce'),
1628 1628
 								'type'        => 'string',
1629
-								'context'     => array( 'view', 'edit' ),
1629
+								'context'     => array('view', 'edit'),
1630 1630
 								'readonly'    => true,
1631 1631
 							),
1632 1632
 							'meta_data'    => array(
1633
-								'description' => __( 'Meta data.', 'woocommerce' ),
1633
+								'description' => __('Meta data.', 'woocommerce'),
1634 1634
 								'type'        => 'array',
1635
-								'context'     => array( 'view', 'edit' ),
1635
+								'context'     => array('view', 'edit'),
1636 1636
 								'items'       => array(
1637 1637
 									'type'       => 'object',
1638 1638
 									'properties' => array(
1639 1639
 										'id'    => array(
1640
-											'description' => __( 'Meta ID.', 'woocommerce' ),
1640
+											'description' => __('Meta ID.', 'woocommerce'),
1641 1641
 											'type'        => 'integer',
1642
-											'context'     => array( 'view', 'edit' ),
1642
+											'context'     => array('view', 'edit'),
1643 1643
 											'readonly'    => true,
1644 1644
 										),
1645 1645
 										'key'   => array(
1646
-											'description' => __( 'Meta key.', 'woocommerce' ),
1646
+											'description' => __('Meta key.', 'woocommerce'),
1647 1647
 											'type'        => 'string',
1648
-											'context'     => array( 'view', 'edit' ),
1648
+											'context'     => array('view', 'edit'),
1649 1649
 										),
1650 1650
 										'value' => array(
1651
-											'description' => __( 'Meta value.', 'woocommerce' ),
1651
+											'description' => __('Meta value.', 'woocommerce'),
1652 1652
 											'type'        => 'mixed',
1653
-											'context'     => array( 'view', 'edit' ),
1653
+											'context'     => array('view', 'edit'),
1654 1654
 										),
1655 1655
 									),
1656 1656
 								),
@@ -1659,44 +1659,44 @@  discard block
 block discarded – undo
1659 1659
 					),
1660 1660
 				),
1661 1661
 				'refunds'              => array(
1662
-					'description' => __( 'List of refunds.', 'woocommerce' ),
1662
+					'description' => __('List of refunds.', 'woocommerce'),
1663 1663
 					'type'        => 'array',
1664
-					'context'     => array( 'view', 'edit' ),
1664
+					'context'     => array('view', 'edit'),
1665 1665
 					'readonly'    => true,
1666 1666
 					'items'       => array(
1667 1667
 						'type'       => 'object',
1668 1668
 						'properties' => array(
1669 1669
 							'id'     => array(
1670
-								'description' => __( 'Refund ID.', 'woocommerce' ),
1670
+								'description' => __('Refund ID.', 'woocommerce'),
1671 1671
 								'type'        => 'integer',
1672
-								'context'     => array( 'view', 'edit' ),
1672
+								'context'     => array('view', 'edit'),
1673 1673
 								'readonly'    => true,
1674 1674
 							),
1675 1675
 							'reason' => array(
1676
-								'description' => __( 'Refund reason.', 'woocommerce' ),
1676
+								'description' => __('Refund reason.', 'woocommerce'),
1677 1677
 								'type'        => 'string',
1678
-								'context'     => array( 'view', 'edit' ),
1678
+								'context'     => array('view', 'edit'),
1679 1679
 								'readonly'    => true,
1680 1680
 							),
1681 1681
 							'total'  => array(
1682
-								'description' => __( 'Refund total.', 'woocommerce' ),
1682
+								'description' => __('Refund total.', 'woocommerce'),
1683 1683
 								'type'        => 'string',
1684
-								'context'     => array( 'view', 'edit' ),
1684
+								'context'     => array('view', 'edit'),
1685 1685
 								'readonly'    => true,
1686 1686
 							),
1687 1687
 						),
1688 1688
 					),
1689 1689
 				),
1690 1690
 				'set_paid'             => array(
1691
-					'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ),
1691
+					'description' => __('Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce'),
1692 1692
 					'type'        => 'boolean',
1693 1693
 					'default'     => false,
1694
-					'context'     => array( 'edit' ),
1694
+					'context'     => array('edit'),
1695 1695
 				),
1696 1696
 			),
1697 1697
 		);
1698 1698
 
1699
-		return $this->add_additional_fields_schema( $schema );
1699
+		return $this->add_additional_fields_schema($schema);
1700 1700
 	}
1701 1701
 
1702 1702
 	/**
@@ -1707,38 +1707,38 @@  discard block
 block discarded – undo
1707 1707
 	public function get_collection_params() {
1708 1708
 		$params = parent::get_collection_params();
1709 1709
 
1710
-		$params['status']   = array(
1710
+		$params['status'] = array(
1711 1711
 			'default'           => 'any',
1712
-			'description'       => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ),
1712
+			'description'       => __('Limit result set to orders which have specific statuses.', 'woocommerce'),
1713 1713
 			'type'              => 'array',
1714 1714
 			'items'             => array(
1715 1715
 				'type' => 'string',
1716
-				'enum' => array_merge( array( 'any', 'trash' ), $this->get_order_statuses() ),
1716
+				'enum' => array_merge(array('any', 'trash'), $this->get_order_statuses()),
1717 1717
 			),
1718 1718
 			'validate_callback' => 'rest_validate_request_arg',
1719 1719
 		);
1720 1720
 		$params['customer'] = array(
1721
-			'description'       => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ),
1721
+			'description'       => __('Limit result set to orders assigned a specific customer.', 'woocommerce'),
1722 1722
 			'type'              => 'integer',
1723 1723
 			'sanitize_callback' => 'absint',
1724 1724
 			'validate_callback' => 'rest_validate_request_arg',
1725 1725
 		);
1726
-		$params['product']  = array(
1727
-			'description'       => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ),
1726
+		$params['product'] = array(
1727
+			'description'       => __('Limit result set to orders assigned a specific product.', 'woocommerce'),
1728 1728
 			'type'              => 'integer',
1729 1729
 			'sanitize_callback' => 'absint',
1730 1730
 			'validate_callback' => 'rest_validate_request_arg',
1731 1731
 		);
1732
-		$params['dp']       = array(
1732
+		$params['dp'] = array(
1733 1733
 			'default'           => wc_get_price_decimals(),
1734
-			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
1734
+			'description'       => __('Number of decimal points to use in each resource.', 'woocommerce'),
1735 1735
 			'type'              => 'integer',
1736 1736
 			'sanitize_callback' => 'absint',
1737 1737
 			'validate_callback' => 'rest_validate_request_arg',
1738 1738
 		);
1739 1739
 		// This needs to remain a string to support extensions that filter Order Number.
1740 1740
 		$params['number'] = array(
1741
-			'description'       => __( 'Limit result set to orders matching part of an order number.', 'woocommerce' ),
1741
+			'description'       => __('Limit result set to orders matching part of an order number.', 'woocommerce'),
1742 1742
 			'type'              => 'string',
1743 1743
 			'validate_callback' => 'rest_validate_request_arg',
1744 1744
 		);
@@ -1755,27 +1755,27 @@  discard block
 block discarded – undo
1755 1755
 	 * @param \WC_Order        $order   Order data.
1756 1756
 	 * @return bool
1757 1757
 	 */
1758
-	protected function calculate_coupons( $request, $order ) {
1759
-		if ( ! isset( $request['coupon_lines'] ) || ! is_array( $request['coupon_lines'] ) ) {
1758
+	protected function calculate_coupons($request, $order) {
1759
+		if ( ! isset($request['coupon_lines']) || ! is_array($request['coupon_lines'])) {
1760 1760
 			return false;
1761 1761
 		}
1762 1762
 
1763 1763
 		// Remove all coupons first to ensure calculation is correct.
1764
-		foreach ( $order->get_items( 'coupon' ) as $coupon ) {
1765
-			$order->remove_coupon( $coupon->get_code() );
1764
+		foreach ($order->get_items('coupon') as $coupon) {
1765
+			$order->remove_coupon($coupon->get_code());
1766 1766
 		}
1767 1767
 
1768
-		foreach ( $request['coupon_lines'] as $item ) {
1769
-			if ( is_array( $item ) ) {
1770
-				if ( empty( $item['id'] ) ) {
1771
-					if ( empty( $item['code'] ) ) {
1772
-						throw new \WC_REST_Exception( 'woocommerce_rest_invalid_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
1768
+		foreach ($request['coupon_lines'] as $item) {
1769
+			if (is_array($item)) {
1770
+				if (empty($item['id'])) {
1771
+					if (empty($item['code'])) {
1772
+						throw new \WC_REST_Exception('woocommerce_rest_invalid_coupon', __('Coupon code is required.', 'woocommerce'), 400);
1773 1773
 					}
1774 1774
 
1775
-					$results = $order->apply_coupon( wc_clean( $item['code'] ) );
1775
+					$results = $order->apply_coupon(wc_clean($item['code']));
1776 1776
 
1777
-					if ( is_wp_error( $results ) ) {
1778
-						throw new \WC_REST_Exception( 'woocommerce_rest_' . $results->get_error_code(), $results->get_error_message(), 400 );
1777
+					if (is_wp_error($results)) {
1778
+						throw new \WC_REST_Exception('woocommerce_rest_' . $results->get_error_code(), $results->get_error_message(), 400);
1779 1779
 					}
1780 1780
 				}
1781 1781
 			}
Please login to merge, or discard this patch.
src/Controllers/Version4/ProductAttributeTerms.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Controllers\Version4;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 /**
15 15
  * REST API Product Attribute Terms controller class.
@@ -33,32 +33,32 @@  discard block
 block discarded – undo
33 33
 			array(
34 34
 				'args'   => array(
35 35
 					'attribute_id' => array(
36
-						'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
36
+						'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'),
37 37
 						'type'        => 'integer',
38 38
 					),
39 39
 				),
40 40
 				array(
41 41
 					'methods'             => \WP_REST_Server::READABLE,
42
-					'callback'            => array( $this, 'get_items' ),
43
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
42
+					'callback'            => array($this, 'get_items'),
43
+					'permission_callback' => array($this, 'get_items_permissions_check'),
44 44
 					'args'                => $this->get_collection_params(),
45 45
 				),
46 46
 				array(
47 47
 					'methods'             => \WP_REST_Server::CREATABLE,
48
-					'callback'            => array( $this, 'create_item' ),
49
-					'permission_callback' => array( $this, 'create_item_permissions_check' ),
48
+					'callback'            => array($this, 'create_item'),
49
+					'permission_callback' => array($this, 'create_item_permissions_check'),
50 50
 					'args'                => array_merge(
51
-						$this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ),
51
+						$this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
52 52
 						array(
53 53
 							'name' => array(
54 54
 								'type'        => 'string',
55
-								'description' => __( 'Name for the resource.', 'woocommerce' ),
55
+								'description' => __('Name for the resource.', 'woocommerce'),
56 56
 								'required'    => true,
57 57
 							),
58 58
 						)
59 59
 					),
60 60
 				),
61
-				'schema' => array( $this, 'get_public_item_schema' ),
61
+				'schema' => array($this, 'get_public_item_schema'),
62 62
 			),
63 63
 			true
64 64
 		);
@@ -69,41 +69,41 @@  discard block
 block discarded – undo
69 69
 			array(
70 70
 				'args'   => array(
71 71
 					'id'           => array(
72
-						'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
72
+						'description' => __('Unique identifier for the resource.', 'woocommerce'),
73 73
 						'type'        => 'integer',
74 74
 					),
75 75
 					'attribute_id' => array(
76
-						'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
76
+						'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'),
77 77
 						'type'        => 'integer',
78 78
 					),
79 79
 				),
80 80
 				array(
81 81
 					'methods'             => \WP_REST_Server::READABLE,
82
-					'callback'            => array( $this, 'get_item' ),
83
-					'permission_callback' => array( $this, 'get_item_permissions_check' ),
82
+					'callback'            => array($this, 'get_item'),
83
+					'permission_callback' => array($this, 'get_item_permissions_check'),
84 84
 					'args'                => array(
85
-						'context'         => $this->get_context_param( array( 'default' => 'view' ) ),
85
+						'context'         => $this->get_context_param(array('default' => 'view')),
86 86
 					),
87 87
 				),
88 88
 				array(
89 89
 					'methods'             => \WP_REST_Server::EDITABLE,
90
-					'callback'            => array( $this, 'update_item' ),
91
-					'permission_callback' => array( $this, 'update_item_permissions_check' ),
92
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
90
+					'callback'            => array($this, 'update_item'),
91
+					'permission_callback' => array($this, 'update_item_permissions_check'),
92
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
93 93
 				),
94 94
 				array(
95 95
 					'methods'             => \WP_REST_Server::DELETABLE,
96
-					'callback'            => array( $this, 'delete_item' ),
97
-					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
96
+					'callback'            => array($this, 'delete_item'),
97
+					'permission_callback' => array($this, 'delete_item_permissions_check'),
98 98
 					'args'                => array(
99 99
 						'force' => array(
100 100
 							'default'     => false,
101 101
 							'type'        => 'boolean',
102
-							'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
102
+							'description' => __('Required to be true, as resource does not support trashing.', 'woocommerce'),
103 103
 						),
104 104
 					),
105 105
 				),
106
-				'schema' => array( $this, 'get_public_item_schema' ),
106
+				'schema' => array($this, 'get_public_item_schema'),
107 107
 			),
108 108
 			true
109 109
 		);
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
 			array(
115 115
 				'args' => array(
116 116
 					'attribute_id' => array(
117
-						'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
117
+						'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'),
118 118
 						'type'        => 'integer',
119 119
 					),
120 120
 				),
121 121
 				array(
122 122
 					'methods'             => \WP_REST_Server::EDITABLE,
123
-					'callback'            => array( $this, 'batch_items' ),
124
-					'permission_callback' => array( $this, 'batch_items_permissions_check' ),
125
-					'args'                => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ),
123
+					'callback'            => array($this, 'batch_items'),
124
+					'permission_callback' => array($this, 'batch_items_permissions_check'),
125
+					'args'                => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
126 126
 				),
127
-				'schema' => array( $this, 'get_public_batch_schema' ),
127
+				'schema' => array($this, 'get_public_batch_schema'),
128 128
 			),
129 129
 			true
130 130
 		);
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 * @param \WP_REST_Request $request Request params.
138 138
 	 * @return \WP_REST_Response $response
139 139
 	 */
140
-	public function prepare_item_for_response( $item, $request ) {
140
+	public function prepare_item_for_response($item, $request) {
141 141
 		// Get term order.
142
-		$menu_order = get_term_meta( $item->term_id, 'order_' . $this->taxonomy, true );
142
+		$menu_order = get_term_meta($item->term_id, 'order_' . $this->taxonomy, true);
143 143
 
144 144
 		$data = array(
145 145
 			'id'          => (int) $item->term_id,
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 			'count'       => (int) $item->count,
151 151
 		);
152 152
 
153
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
154
-		$data    = $this->add_additional_fields_to_object( $data, $request );
155
-		$data    = $this->filter_response_by_context( $data, $context );
153
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
154
+		$data    = $this->add_additional_fields_to_object($data, $request);
155
+		$data    = $this->filter_response_by_context($data, $context);
156 156
 
157
-		$response = rest_ensure_response( $data );
157
+		$response = rest_ensure_response($data);
158 158
 
159
-		$response->add_links( $this->prepare_links( $item, $request ) );
159
+		$response->add_links($this->prepare_links($item, $request));
160 160
 
161 161
 		/**
162 162
 		 * Filter a term item returned from the API.
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		 * @param object            $item      The original term object.
168 168
 		 * @param \WP_REST_Request   $request   Request used to generate the response.
169 169
 		 */
170
-		return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
170
+		return apply_filters("woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request);
171 171
 	}
172 172
 
173 173
 	/**
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 * @param \WP_REST_Request $request Request params.
178 178
 	 * @return bool|\WP_Error
179 179
 	 */
180
-	protected function update_term_meta_fields( $term, $request ) {
180
+	protected function update_term_meta_fields($term, $request) {
181 181
 		$id = (int) $term->term_id;
182 182
 
183
-		update_term_meta( $id, 'order_' . $this->taxonomy, $request['menu_order'] );
183
+		update_term_meta($id, 'order_' . $this->taxonomy, $request['menu_order']);
184 184
 
185 185
 		return true;
186 186
 	}
@@ -197,49 +197,49 @@  discard block
 block discarded – undo
197 197
 			'type'                 => 'object',
198 198
 			'properties'           => array(
199 199
 				'id' => array(
200
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
200
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
201 201
 					'type'        => 'integer',
202
-					'context'     => array( 'view', 'edit' ),
202
+					'context'     => array('view', 'edit'),
203 203
 					'readonly'    => true,
204 204
 				),
205 205
 				'name' => array(
206
-					'description' => __( 'Term name.', 'woocommerce' ),
206
+					'description' => __('Term name.', 'woocommerce'),
207 207
 					'type'        => 'string',
208
-					'context'     => array( 'view', 'edit' ),
208
+					'context'     => array('view', 'edit'),
209 209
 					'arg_options' => array(
210 210
 						'sanitize_callback' => 'sanitize_text_field',
211 211
 					),
212 212
 				),
213 213
 				'slug' => array(
214
-					'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
214
+					'description' => __('An alphanumeric identifier for the resource unique to its type.', 'woocommerce'),
215 215
 					'type'        => 'string',
216
-					'context'     => array( 'view', 'edit' ),
216
+					'context'     => array('view', 'edit'),
217 217
 					'arg_options' => array(
218 218
 						'sanitize_callback' => 'sanitize_title',
219 219
 					),
220 220
 				),
221 221
 				'description' => array(
222
-					'description' => __( 'HTML description of the resource.', 'woocommerce' ),
222
+					'description' => __('HTML description of the resource.', 'woocommerce'),
223 223
 					'type'        => 'string',
224
-					'context'     => array( 'view', 'edit' ),
224
+					'context'     => array('view', 'edit'),
225 225
 					'arg_options' => array(
226 226
 						'sanitize_callback' => 'wp_filter_post_kses',
227 227
 					),
228 228
 				),
229 229
 				'menu_order' => array(
230
-					'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
230
+					'description' => __('Menu order, used to custom sort the resource.', 'woocommerce'),
231 231
 					'type'        => 'integer',
232
-					'context'     => array( 'view', 'edit' ),
232
+					'context'     => array('view', 'edit'),
233 233
 				),
234 234
 				'count' => array(
235
-					'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
235
+					'description' => __('Number of published products for the resource.', 'woocommerce'),
236 236
 					'type'        => 'integer',
237
-					'context'     => array( 'view', 'edit' ),
237
+					'context'     => array('view', 'edit'),
238 238
 					'readonly'    => true,
239 239
 				),
240 240
 			),
241 241
 		);
242 242
 
243
-		return $this->add_additional_fields_schema( $schema );
243
+		return $this->add_additional_fields_schema($schema);
244 244
 	}
245 245
 }
Please login to merge, or discard this patch.
src/Controllers/Version4/Data/Continents.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Controllers\Version4\Data;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Controllers\Version4\Data as DataController;
15 15
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 			array(
38 38
 				array(
39 39
 					'methods'             => \WP_REST_Server::READABLE,
40
-					'callback'            => array( $this, 'get_items' ),
41
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
40
+					'callback'            => array($this, 'get_items'),
41
+					'permission_callback' => array($this, 'get_items_permissions_check'),
42 42
 				),
43
-				'schema' => array( $this, 'get_public_item_schema' ),
43
+				'schema' => array($this, 'get_public_item_schema'),
44 44
 			)
45 45
 		);
46 46
 		register_rest_route(
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
 			array(
50 50
 				array(
51 51
 					'methods'             => \WP_REST_Server::READABLE,
52
-					'callback'            => array( $this, 'get_item' ),
53
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
52
+					'callback'            => array($this, 'get_item'),
53
+					'permission_callback' => array($this, 'get_items_permissions_check'),
54 54
 					'args'                => array(
55 55
 						'continent' => array(
56
-							'description' => __( '2 character continent code.', 'woocommerce' ),
56
+							'description' => __('2 character continent code.', 'woocommerce'),
57 57
 							'type'        => 'string',
58 58
 						),
59 59
 					),
60 60
 				),
61
-				'schema' => array( $this, 'get_public_item_schema' ),
61
+				'schema' => array($this, 'get_public_item_schema'),
62 62
 			)
63 63
 		);
64 64
 	}
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 	 * @param  \WP_REST_Request $request        Request data.
72 72
 	 * @return array|mixed Response data, ready for insertion into collection data.
73 73
 	 */
74
-	public function get_continent( $continent_code = false, $request ) {
74
+	public function get_continent($continent_code = false, $request) {
75 75
 		$continents  = WC()->countries->get_continents();
76 76
 		$countries   = WC()->countries->get_countries();
77 77
 		$states      = WC()->countries->get_states();
78 78
 		$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
79 79
 		$data        = array();
80 80
 
81
-		if ( ! array_key_exists( $continent_code, $continents ) ) {
81
+		if ( ! array_key_exists($continent_code, $continents)) {
82 82
 			return false;
83 83
 		}
84 84
 
85
-		$continent_list = $continents[ $continent_code ];
85
+		$continent_list = $continents[$continent_code];
86 86
 
87 87
 		$continent = array(
88 88
 			'code' => $continent_code,
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 		);
91 91
 
92 92
 		$local_countries = array();
93
-		foreach ( $continent_list['countries'] as $country_code ) {
94
-			if ( isset( $countries[ $country_code ] ) ) {
93
+		foreach ($continent_list['countries'] as $country_code) {
94
+			if (isset($countries[$country_code])) {
95 95
 				$country = array(
96 96
 					'code' => $country_code,
97
-					'name' => $countries[ $country_code ],
97
+					'name' => $countries[$country_code],
98 98
 				);
99 99
 
100 100
 				// If we have detailed locale information include that in the response.
101
-				if ( array_key_exists( $country_code, $locale_info ) ) {
101
+				if (array_key_exists($country_code, $locale_info)) {
102 102
 					// Defensive programming against unexpected changes in locale-info.php.
103 103
 					$country_data = wp_parse_args(
104
-						$locale_info[ $country_code ],
104
+						$locale_info[$country_code],
105 105
 						array(
106 106
 							'currency_code'  => 'USD',
107 107
 							'currency_pos'   => 'left',
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 						)
114 114
 					);
115 115
 
116
-					$country = array_merge( $country, $country_data );
116
+					$country = array_merge($country, $country_data);
117 117
 				}
118 118
 
119 119
 				$local_states = array();
120
-				if ( isset( $states[ $country_code ] ) ) {
121
-					foreach ( $states[ $country_code ] as $state_code => $state_name ) {
120
+				if (isset($states[$country_code])) {
121
+					foreach ($states[$country_code] as $state_code => $state_name) {
122 122
 						$local_states[] = array(
123 123
 							'code' => $state_code,
124 124
 							'name' => $state_name,
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 					'thousand_sep',
141 141
 					'weight_unit',
142 142
 				);
143
-				$country = array_intersect_key( $country, array_flip( $allowed ) );
143
+				$country = array_intersect_key($country, array_flip($allowed));
144 144
 
145 145
 				$local_countries[] = $country;
146 146
 			}
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	 * @param  \WP_REST_Request $request Request data.
158 158
 	 * @return \WP_Error\WP_REST_Response
159 159
 	 */
160
-	public function get_items( $request ) {
160
+	public function get_items($request) {
161 161
 		$continents = WC()->countries->get_continents();
162 162
 		$data       = array();
163 163
 
164
-		foreach ( array_keys( $continents ) as $continent_code ) {
165
-			$continent = $this->get_continent( $continent_code, $request );
166
-			$response  = $this->prepare_item_for_response( $continent, $request );
167
-			$data[]    = $this->prepare_response_for_collection( $response );
164
+		foreach (array_keys($continents) as $continent_code) {
165
+			$continent = $this->get_continent($continent_code, $request);
166
+			$response  = $this->prepare_item_for_response($continent, $request);
167
+			$data[]    = $this->prepare_response_for_collection($response);
168 168
 		}
169 169
 
170
-		return rest_ensure_response( $data );
170
+		return rest_ensure_response($data);
171 171
 	}
172 172
 
173 173
 	/**
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
 	 * @param  \WP_REST_Request $request Request data.
178 178
 	 * @return \WP_Error|\WP_REST_Response
179 179
 	 */
180
-	public function get_item( $request ) {
181
-		$data = $this->get_continent( strtoupper( $request['location'] ), $request );
182
-		if ( empty( $data ) ) {
183
-			return new \WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
180
+	public function get_item($request) {
181
+		$data = $this->get_continent(strtoupper($request['location']), $request);
182
+		if (empty($data)) {
183
+			return new \WP_Error('woocommerce_rest_data_invalid_location', __('There are no locations matching these parameters.', 'woocommerce'), array('status' => 404));
184 184
 		}
185
-		return $this->prepare_item_for_response( $data, $request );
185
+		return $this->prepare_item_for_response($data, $request);
186 186
 	}
187 187
 
188 188
 	/**
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	 * @param \WP_REST_Request $request Request object.
194 194
 	 * @return \WP_REST_Response $response Response data.
195 195
 	 */
196
-	public function prepare_item_for_response( $item, $request ) {
197
-		$data     = $this->add_additional_fields_to_object( $item, $request );
198
-		$data     = $this->filter_response_by_context( $data, 'view' );
199
-		$response = rest_ensure_response( $data );
196
+	public function prepare_item_for_response($item, $request) {
197
+		$data     = $this->add_additional_fields_to_object($item, $request);
198
+		$data     = $this->filter_response_by_context($data, 'view');
199
+		$response = rest_ensure_response($data);
200 200
 
201
-		$response->add_links( $this->prepare_links( $item ) );
201
+		$response->add_links($this->prepare_links($item));
202 202
 
203 203
 		/**
204 204
 		 * Filter the location list returned from the API.
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		 * @param array             $item     The original list of continent(s), countries, and states.
210 210
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
211 211
 		 */
212
-		return apply_filters( 'woocommerce_rest_prepare_data_continent', $response, $item, $request );
212
+		return apply_filters('woocommerce_rest_prepare_data_continent', $response, $item, $request);
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
 	 * @param object $item Data object.
219 219
 	 * @return array Links for the given continent.
220 220
 	 */
221
-	protected function prepare_links( $item ) {
222
-		$continent_code = strtolower( $item['code'] );
221
+	protected function prepare_links($item) {
222
+		$continent_code = strtolower($item['code']);
223 223
 		$links          = array(
224 224
 			'self'       => array(
225
-				'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code ) ),
225
+				'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code)),
226 226
 			),
227 227
 			'collection' => array(
228
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
228
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
229 229
 			),
230 230
 		);
231 231
 		return $links;
@@ -245,88 +245,88 @@  discard block
 block discarded – undo
245 245
 			'properties' => array(
246 246
 				'code'      => array(
247 247
 					'type'        => 'string',
248
-					'description' => __( '2 character continent code.', 'woocommerce' ),
249
-					'context'     => array( 'view' ),
248
+					'description' => __('2 character continent code.', 'woocommerce'),
249
+					'context'     => array('view'),
250 250
 					'readonly'    => true,
251 251
 				),
252 252
 				'name'      => array(
253 253
 					'type'        => 'string',
254
-					'description' => __( 'Full name of continent.', 'woocommerce' ),
255
-					'context'     => array( 'view' ),
254
+					'description' => __('Full name of continent.', 'woocommerce'),
255
+					'context'     => array('view'),
256 256
 					'readonly'    => true,
257 257
 				),
258 258
 				'countries' => array(
259 259
 					'type'        => 'array',
260
-					'description' => __( 'List of countries on this continent.', 'woocommerce' ),
261
-					'context'     => array( 'view' ),
260
+					'description' => __('List of countries on this continent.', 'woocommerce'),
261
+					'context'     => array('view'),
262 262
 					'readonly'    => true,
263 263
 					'items'       => array(
264 264
 						'type'       => 'object',
265
-						'context'    => array( 'view' ),
265
+						'context'    => array('view'),
266 266
 						'readonly'   => true,
267 267
 						'properties' => array(
268 268
 							'code'           => array(
269 269
 								'type'        => 'string',
270
-								'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
271
-								'context'     => array( 'view' ),
270
+								'description' => __('ISO3166 alpha-2 country code.', 'woocommerce'),
271
+								'context'     => array('view'),
272 272
 								'readonly'    => true,
273 273
 							),
274 274
 							'currency_code'  => array(
275 275
 								'type'        => 'string',
276
-								'description' => __( 'Default ISO4127 alpha-3 currency code for the country.', 'woocommerce' ),
277
-								'context'     => array( 'view' ),
276
+								'description' => __('Default ISO4127 alpha-3 currency code for the country.', 'woocommerce'),
277
+								'context'     => array('view'),
278 278
 								'readonly'    => true,
279 279
 							),
280 280
 							'currency_pos'   => array(
281 281
 								'type'        => 'string',
282
-								'description' => __( 'Currency symbol position for this country.', 'woocommerce' ),
283
-								'context'     => array( 'view' ),
282
+								'description' => __('Currency symbol position for this country.', 'woocommerce'),
283
+								'context'     => array('view'),
284 284
 								'readonly'    => true,
285 285
 							),
286 286
 							'decimal_sep'    => array(
287 287
 								'type'        => 'string',
288
-								'description' => __( 'Decimal separator for displayed prices for this country.', 'woocommerce' ),
289
-								'context'     => array( 'view' ),
288
+								'description' => __('Decimal separator for displayed prices for this country.', 'woocommerce'),
289
+								'context'     => array('view'),
290 290
 								'readonly'    => true,
291 291
 							),
292 292
 							'dimension_unit' => array(
293 293
 								'type'        => 'string',
294
-								'description' => __( 'The unit lengths are defined in for this country.', 'woocommerce' ),
295
-								'context'     => array( 'view' ),
294
+								'description' => __('The unit lengths are defined in for this country.', 'woocommerce'),
295
+								'context'     => array('view'),
296 296
 								'readonly'    => true,
297 297
 							),
298 298
 							'name'           => array(
299 299
 								'type'        => 'string',
300
-								'description' => __( 'Full name of country.', 'woocommerce' ),
301
-								'context'     => array( 'view' ),
300
+								'description' => __('Full name of country.', 'woocommerce'),
301
+								'context'     => array('view'),
302 302
 								'readonly'    => true,
303 303
 							),
304 304
 							'num_decimals'   => array(
305 305
 								'type'        => 'integer',
306
-								'description' => __( 'Number of decimal points shown in displayed prices for this country.', 'woocommerce' ),
307
-								'context'     => array( 'view' ),
306
+								'description' => __('Number of decimal points shown in displayed prices for this country.', 'woocommerce'),
307
+								'context'     => array('view'),
308 308
 								'readonly'    => true,
309 309
 							),
310 310
 							'states'         => array(
311 311
 								'type'        => 'array',
312
-								'description' => __( 'List of states in this country.', 'woocommerce' ),
313
-								'context'     => array( 'view' ),
312
+								'description' => __('List of states in this country.', 'woocommerce'),
313
+								'context'     => array('view'),
314 314
 								'readonly'    => true,
315 315
 								'items'       => array(
316 316
 									'type'       => 'object',
317
-									'context'    => array( 'view' ),
317
+									'context'    => array('view'),
318 318
 									'readonly'   => true,
319 319
 									'properties' => array(
320 320
 										'code' => array(
321 321
 											'type'        => 'string',
322
-											'description' => __( 'State code.', 'woocommerce' ),
323
-											'context'     => array( 'view' ),
322
+											'description' => __('State code.', 'woocommerce'),
323
+											'context'     => array('view'),
324 324
 											'readonly'    => true,
325 325
 										),
326 326
 										'name' => array(
327 327
 											'type'        => 'string',
328
-											'description' => __( 'Full name of state.', 'woocommerce' ),
329
-											'context'     => array( 'view' ),
328
+											'description' => __('Full name of state.', 'woocommerce'),
329
+											'context'     => array('view'),
330 330
 											'readonly'    => true,
331 331
 										),
332 332
 									),
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 							),
335 335
 							'thousand_sep'   => array(
336 336
 								'type'        => 'string',
337
-								'description' => __( 'Thousands separator for displayed prices in this country.', 'woocommerce' ),
338
-								'context'     => array( 'view' ),
337
+								'description' => __('Thousands separator for displayed prices in this country.', 'woocommerce'),
338
+								'context'     => array('view'),
339 339
 								'readonly'    => true,
340 340
 							),
341 341
 							'weight_unit'    => array(
342 342
 								'type'        => 'string',
343
-								'description' => __( 'The unit weights are defined in for this country.', 'woocommerce' ),
344
-								'context'     => array( 'view' ),
343
+								'description' => __('The unit weights are defined in for this country.', 'woocommerce'),
344
+								'context'     => array('view'),
345 345
 								'readonly'    => true,
346 346
 							),
347 347
 						),
@@ -350,6 +350,6 @@  discard block
 block discarded – undo
350 350
 			),
351 351
 		);
352 352
 
353
-		return $this->add_additional_fields_schema( $schema );
353
+		return $this->add_additional_fields_schema($schema);
354 354
 	}
355 355
 }
Please login to merge, or discard this patch.