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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Admin / API / Reports / Orders / Stats / Controller.php
woocommerce / src / Admin / API / Reports / Orders / Stats Last commit date
Controller.php 1 year ago DataStore.php 1 month ago Query.php 1 year ago Segmenter.php 2 years ago
Controller.php
389 lines
1 <?php
2 /**
3 * REST API Reports orders stats controller
4 *
5 * Handles requests to the /reports/orders/stats endpoint.
6 */
7
8 namespace Automattic\WooCommerce\Admin\API\Reports\Orders\Stats;
9
10 defined( 'ABSPATH' ) || exit;
11
12 use Automattic\WooCommerce\Admin\API\Reports\GenericStatsController;
13 use Automattic\WooCommerce\Admin\API\Reports\OrderAwareControllerTrait;
14 use Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\Query;
15
16 /**
17 * REST API Reports orders stats controller class.
18 *
19 * @internal
20 * @extends \Automattic\WooCommerce\Admin\API\Reports\GenericStatsController
21 */
22 class Controller extends GenericStatsController {
23
24 use OrderAwareControllerTrait;
25
26 /**
27 * Route base.
28 *
29 * @var string
30 */
31 protected $rest_base = 'reports/orders/stats';
32
33 /**
34 * Get data from Orders\Stats\Query.
35 *
36 * @override GenericController::get_datastore_data()
37 *
38 * @param array $query_args Query arguments.
39 * @return mixed Results from the data store.
40 */
41 protected function get_datastore_data( $query_args = array() ) {
42 $query = new Query( $query_args );
43 return $query->get_data();
44 }
45
46 /**
47 * Maps query arguments from the REST request.
48 *
49 * @param array $request Request array.
50 * @return array
51 */
52 protected function prepare_reports_query( $request ) {
53 $args = array();
54 $args['before'] = $request['before'];
55 $args['after'] = $request['after'];
56 $args['interval'] = $request['interval'];
57 $args['page'] = $request['page'];
58 $args['per_page'] = $request['per_page'];
59 $args['orderby'] = $request['orderby'];
60 $args['order'] = $request['order'];
61 $args['fields'] = $request['fields'];
62 $args['match'] = $request['match'];
63 $args['status_is'] = (array) $request['status_is'];
64 $args['status_is_not'] = (array) $request['status_is_not'];
65 $args['product_includes'] = (array) $request['product_includes'];
66 $args['product_excludes'] = (array) $request['product_excludes'];
67 $args['variation_includes'] = (array) $request['variation_includes'];
68 $args['variation_excludes'] = (array) $request['variation_excludes'];
69 $args['coupon_includes'] = (array) $request['coupon_includes'];
70 $args['coupon_excludes'] = (array) $request['coupon_excludes'];
71 $args['tax_rate_includes'] = (array) $request['tax_rate_includes'];
72 $args['tax_rate_excludes'] = (array) $request['tax_rate_excludes'];
73 $args['customer_type'] = $request['customer_type'];
74 $args['refunds'] = $request['refunds'];
75 $args['attribute_is'] = (array) $request['attribute_is'];
76 $args['attribute_is_not'] = (array) $request['attribute_is_not'];
77 $args['category_includes'] = (array) $request['categories'];
78 $args['segmentby'] = $request['segmentby'];
79 $args['force_cache_refresh'] = $request['force_cache_refresh'];
80
81 // For backwards compatibility, `customer` is aliased to `customer_type`.
82 if ( empty( $request['customer_type'] ) && ! empty( $request['customer'] ) ) {
83 $args['customer_type'] = $request['customer'];
84 }
85
86 return $args;
87 }
88
89 /**
90 * Prepare a report data item for serialization.
91 *
92 * @param Array $report Report data item as returned from Data Store.
93 * @param WP_REST_Request $request Request object.
94 * @return WP_REST_Response
95 */
96 public function prepare_item_for_response( $report, $request ) {
97 // Wrap the data in a response object.
98 $response = parent::prepare_item_for_response( $report, $request );
99
100 /**
101 * Filter a report returned from the API.
102 *
103 * Allows modification of the report data right before it is returned.
104 *
105 * @param WP_REST_Response $response The response object.
106 * @param object $report The original report object.
107 * @param WP_REST_Request $request Request used to generate the response.
108 */
109 return apply_filters( 'woocommerce_rest_prepare_report_orders_stats', $response, $report, $request );
110 }
111
112
113 /**
114 * Get the Report's item properties schema.
115 * Will be used by `get_item_schema` as `totals` and `subtotals`.
116 *
117 * @return array
118 */
119 protected function get_item_properties_schema() {
120 return array(
121 'net_revenue' => array(
122 'description' => __( 'Net sales.', 'woocommerce' ),
123 'type' => 'number',
124 'context' => array( 'view', 'edit' ),
125 'readonly' => true,
126 'format' => 'currency',
127 ),
128 'orders_count' => array(
129 'title' => __( 'Orders', 'woocommerce' ),
130 'description' => __( 'Number of orders', 'woocommerce' ),
131 'type' => 'integer',
132 'context' => array( 'view', 'edit' ),
133 'readonly' => true,
134 'indicator' => true,
135 ),
136 'avg_order_value' => array(
137 'description' => __( 'Average order value.', 'woocommerce' ),
138 'type' => 'number',
139 'context' => array( 'view', 'edit' ),
140 'readonly' => true,
141 'indicator' => true,
142 'format' => 'currency',
143 ),
144 'avg_items_per_order' => array(
145 'description' => __( 'Average items per order', 'woocommerce' ),
146 'type' => 'number',
147 'context' => array( 'view', 'edit' ),
148 'readonly' => true,
149 ),
150 'num_items_sold' => array(
151 'description' => __( 'Number of items sold', 'woocommerce' ),
152 'type' => 'integer',
153 'context' => array( 'view', 'edit' ),
154 'readonly' => true,
155 ),
156 'coupons' => array(
157 'description' => __( 'Amount discounted by coupons.', 'woocommerce' ),
158 'type' => 'number',
159 'context' => array( 'view', 'edit' ),
160 'readonly' => true,
161 ),
162 'coupons_count' => array(
163 'description' => __( 'Unique coupons count.', 'woocommerce' ),
164 'type' => 'number',
165 'context' => array( 'view', 'edit' ),
166 'readonly' => true,
167 ),
168 'total_customers' => array(
169 'description' => __( 'Total distinct customers.', 'woocommerce' ),
170 'type' => 'integer',
171 'context' => array( 'view', 'edit' ),
172 'readonly' => true,
173 ),
174 'products' => array(
175 'description' => __( 'Number of distinct products sold.', 'woocommerce' ),
176 'type' => 'number',
177 'context' => array( 'view', 'edit' ),
178 'readonly' => true,
179 ),
180 );
181 }
182
183 /**
184 * Get the Report's schema, conforming to JSON Schema.
185 *
186 * @return array
187 */
188 public function get_item_schema() {
189 $schema = parent::get_item_schema();
190 $schema['title'] = 'report_orders_stats';
191
192 // Products is not shown in intervals.
193 unset( $schema['properties']['intervals']['items']['properties']['subtotals']['properties']['products'] );
194
195 return $this->add_additional_fields_schema( $schema );
196 }
197
198 /**
199 * Get the query params for collections.
200 *
201 * @return array
202 */
203 public function get_collection_params() {
204 $params = parent::get_collection_params();
205 $params['orderby']['enum'] = $this->apply_custom_orderby_filters(
206 array(
207 'date',
208 'net_revenue',
209 'orders_count',
210 'avg_order_value',
211 )
212 );
213 $params['match'] = array(
214 'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),
215 'type' => 'string',
216 'default' => 'all',
217 'enum' => array(
218 'all',
219 'any',
220 ),
221 'validate_callback' => 'rest_validate_request_arg',
222 );
223 $params['status_is'] = array(
224 'description' => __( 'Limit result set to items that have the specified order status.', 'woocommerce' ),
225 'type' => 'array',
226 'sanitize_callback' => 'wp_parse_slug_list',
227 'validate_callback' => 'rest_validate_request_arg',
228 'default' => null,
229 'items' => array(
230 'enum' => self::get_order_statuses(),
231 'type' => 'string',
232 ),
233 );
234 $params['status_is_not'] = array(
235 'description' => __( 'Limit result set to items that don\'t have the specified order status.', 'woocommerce' ),
236 'type' => 'array',
237 'sanitize_callback' => 'wp_parse_slug_list',
238 'validate_callback' => 'rest_validate_request_arg',
239 'items' => array(
240 'enum' => self::get_order_statuses(),
241 'type' => 'string',
242 ),
243 );
244 $params['product_includes'] = array(
245 'description' => __( 'Limit result set to items that have the specified product(s) assigned.', 'woocommerce' ),
246 'type' => 'array',
247 'items' => array(
248 'type' => 'integer',
249 ),
250 'default' => array(),
251 'sanitize_callback' => 'wp_parse_id_list',
252
253 );
254 $params['product_excludes'] = array(
255 'description' => __( 'Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce' ),
256 'type' => 'array',
257 'items' => array(
258 'type' => 'integer',
259 ),
260 'default' => array(),
261 'sanitize_callback' => 'wp_parse_id_list',
262 );
263 // Split assignments for PHPCS complaining on aligned.
264 $params['variation_includes'] = array(
265 'description' => __( 'Limit result set to items that have the specified variation(s) assigned.', 'woocommerce' ),
266 'type' => 'array',
267 'items' => array(
268 'type' => 'integer',
269 ),
270 'default' => array(),
271 'sanitize_callback' => 'wp_parse_id_list',
272 'validate_callback' => 'rest_validate_request_arg',
273 );
274 $params['variation_excludes'] = array(
275 'description' => __( 'Limit result set to items that don\'t have the specified variation(s) assigned.', 'woocommerce' ),
276 'type' => 'array',
277 'items' => array(
278 'type' => 'integer',
279 ),
280 'default' => array(),
281 'validate_callback' => 'rest_validate_request_arg',
282 'sanitize_callback' => 'wp_parse_id_list',
283 );
284 $params['coupon_includes'] = array(
285 'description' => __( 'Limit result set to items that have the specified coupon(s) assigned.', 'woocommerce' ),
286 'type' => 'array',
287 'items' => array(
288 'type' => 'integer',
289 ),
290 'default' => array(),
291 'sanitize_callback' => 'wp_parse_id_list',
292 );
293 $params['coupon_excludes'] = array(
294 'description' => __( 'Limit result set to items that don\'t have the specified coupon(s) assigned.', 'woocommerce' ),
295 'type' => 'array',
296 'items' => array(
297 'type' => 'integer',
298 ),
299 'default' => array(),
300 'sanitize_callback' => 'wp_parse_id_list',
301 );
302 $params['tax_rate_includes'] = array(
303 'description' => __( 'Limit result set to items that have the specified tax rate(s) assigned.', 'woocommerce' ),
304 'type' => 'array',
305 'items' => array(
306 'type' => 'integer',
307 ),
308 'default' => array(),
309 'sanitize_callback' => 'wp_parse_id_list',
310 'validate_callback' => 'rest_validate_request_arg',
311 );
312 $params['tax_rate_excludes'] = array(
313 'description' => __( 'Limit result set to items that don\'t have the specified tax rate(s) assigned.', 'woocommerce' ),
314 'type' => 'array',
315 'items' => array(
316 'type' => 'integer',
317 ),
318 'default' => array(),
319 'validate_callback' => 'rest_validate_request_arg',
320 'sanitize_callback' => 'wp_parse_id_list',
321 );
322 $params['customer'] = array(
323 'description' => __( 'Alias for customer_type (deprecated).', 'woocommerce' ),
324 'type' => 'string',
325 'enum' => array(
326 'new',
327 'returning',
328 ),
329 'validate_callback' => 'rest_validate_request_arg',
330 );
331 $params['customer_type'] = array(
332 'description' => __( 'Limit result set to orders that have the specified customer_type', 'woocommerce' ),
333 'type' => 'string',
334 'enum' => array(
335 'new',
336 'returning',
337 ),
338 'validate_callback' => 'rest_validate_request_arg',
339 );
340 $params['refunds'] = array(
341 'description' => __( 'Limit result set to specific types of refunds.', 'woocommerce' ),
342 'type' => 'string',
343 'default' => '',
344 'enum' => array(
345 '',
346 'all',
347 'partial',
348 'full',
349 'none',
350 ),
351 'validate_callback' => 'rest_validate_request_arg',
352 );
353 $params['attribute_is'] = array(
354 'description' => __( 'Limit result set to orders that include products with the specified attributes.', 'woocommerce' ),
355 'type' => 'array',
356 'items' => array(
357 'type' => 'array',
358 ),
359 'default' => array(),
360 'validate_callback' => 'rest_validate_request_arg',
361 );
362 $params['attribute_is_not'] = array(
363 'description' => __( 'Limit result set to orders that don\'t include products with the specified attributes.', 'woocommerce' ),
364 'type' => 'array',
365 'items' => array(
366 'type' => 'array',
367 ),
368 'default' => array(),
369 'validate_callback' => 'rest_validate_request_arg',
370 );
371 $params['segmentby'] = array(
372 'description' => __( 'Segment the response by additional constraint.', 'woocommerce' ),
373 'type' => 'string',
374 'enum' => array(
375 'product',
376 'category',
377 'variation',
378 'coupon',
379 'customer_type', // new vs returning.
380 ),
381 'validate_callback' => 'rest_validate_request_arg',
382 );
383 unset( $params['intervals'] );
384 unset( $params['fields'] );
385
386 return $params;
387 }
388 }
389