Automattic\WooCommerce\Admin\API\Reports\Categories

Controller{} │ WC 1.0└─ ExportableInterface, GenericController

REST API Reports categories controller class.

Использование

$Controller = new Controller();
// use class methods

Методы

  1. public get_data()
  2. public apply_filters(
  3. public array(
  4. public get_collection_params()
  5. public __( 'Amount of items sold.', 'woocommerce' )
  6. public get_export_columns()
  7. public prepare_item_for_export( $item )
  8. public get_item_schema()
  9. public get_order_statuses()
  10. public apply_custom_orderby_filters(
  11. public prepare_item_for_response( $report, $request )
  12. public add_links( $this->prepare_links( $report ) )
  13. ERROR: no method name found on line ``
  14. ERROR: no method name found on line `* Get data from `'categories'` GenericQuery.`
  15. ERROR: no method name found on line `*/`
  16. ERROR: no method name found on line `/**`
  17. ERROR: no method name found on line `$args['extended_info'] = $request['extended_info'];`
  18. ERROR: no method name found on line ``
  19. ERROR: no method name found on line ``
  20. ERROR: no method name found on line `* @param \Automattic\WooCommerce\Admin\API\Reports\GenericQuery $object Object data.`
  21. ERROR: no method name found on line ``
  22. ERROR: no method name found on line ``
  23. ERROR: no method name found on line ``
  24. ERROR: no method name found on line ``
  25. ERROR: no method name found on line `);`
  26. ERROR: no method name found on line `* @return array Key value pair of Column ID => Label.`
  27. ERROR: no method name found on line `),`
  28. ERROR: no method name found on line `'type' => 'array',`
  29. ERROR: no method name found on line `'type' => 'boolean',`
  30. ERROR: no method name found on line ``
  31. ERROR: no method name found on line ``
  32. ERROR: no method name found on line `);`
  33. ERROR: no method name found on line ``
  34. ERROR: no method name found on line ``
  35. ERROR: no method name found on line `'week',`
  36. ERROR: no method name found on line `);`
  37. ERROR: no method name found on line `'sanitize_callback' => 'wc_string_to_bool',`
  38. ERROR: no method name found on line ``
  39. ERROR: no method name found on line ``
  40. ERROR: no method name found on line `*/`
  41. ERROR: no method name found on line ``
  42. ERROR: no method name found on line ``
  43. ERROR: no method name found on line ``
  44. ERROR: no method name found on line ``
  45. ERROR: no method name found on line `'validate_callback' => 'rest_validate_request_arg',`
  46. ERROR: no method name found on line ``
  47. ERROR: no method name found on line `* Filter to add or remove column names from the categories report for`
  48. ERROR: no method name found on line ``
  49. ERROR: no method name found on line ``
  50. ERROR: no method name found on line ``
  51. ERROR: no method name found on line ``
  52. ERROR: no method name found on line `* export.`
  53. ERROR: no method name found on line ``
  54. ERROR: no method name found on line ``
  55. ERROR: no method name found on line ``
  56. ERROR: no method name found on line `),`
  57. ERROR: no method name found on line `'readonly' => true,`
  58. ERROR: no method name found on line `)`
  59. ERROR: no method name found on line `);`
  60. ERROR: no method name found on line `'type' => 'array',`
  61. ERROR: no method name found on line ``
  62. ERROR: no method name found on line `'week',`
  63. ERROR: no method name found on line `* Get the column names for export.`
  64. ERROR: no method name found on line ``
  65. ERROR: no method name found on line ``
  66. ERROR: no method name found on line `'month',`
  67. ERROR: no method name found on line ``
  68. ERROR: no method name found on line ``
  69. ERROR: no method name found on line ``
  70. ERROR: no method name found on line ``
  71. ERROR: no method name found on line `*/`
  72. ERROR: no method name found on line `'woocommerce_report_categories_prepare_export_item',`
  73. ERROR: no method name found on line ``
  74. ERROR: no method name found on line `'title' => 'report_categories',`
  75. ERROR: no method name found on line ``
  76. ERROR: no method name found on line ``
  77. ERROR: no method name found on line `'sanitize_callback' => 'wp_parse_slug_list',`
  78. ERROR: no method name found on line `'default' => false,`
  79. ERROR: no method name found on line `'hour',`
  80. ERROR: no method name found on line ``
  81. ERROR: no method name found on line `'type' => 'integer',`
  82. ERROR: no method name found on line `'type' => 'string',`
  83. ERROR: no method name found on line `* @return array Key value pair of Column ID => Label.`
  84. ERROR: no method name found on line `'hour',`
  85. ERROR: no method name found on line `'type' => 'string',`
  86. ERROR: no method name found on line ``
  87. ERROR: no method name found on line `);`
  88. ERROR: no method name found on line `);`
  89. ERROR: no method name found on line `'type' => 'array',`
  90. ERROR: no method name found on line ``
  91. ERROR: no method name found on line ``
  92. ERROR: no method name found on line ``
  93. protected get_datastore_data( $query_args = array() )
  94. ERROR: no method name found on line `$args['after'] = $request['after'];`
  95. ERROR: no method name found on line `$args['orderby'] = $request['orderby'];`
  96. ERROR: no method name found on line `}`
  97. ERROR: no method name found on line `*/`
  98. ERROR: no method name found on line `*/`
  99. ERROR: no method name found on line `$args['status_is'] = (array) $request['status_is'];`
  100. ERROR: no method name found on line `*/`
  101. ERROR: no method name found on line `* Prepare links for the request.`
  102. ERROR: no method name found on line ``
  103. ERROR: no method name found on line `$args['per_page'] = $request['per_page'];`
  104. protected prepare_reports_query( $request )
  105. ERROR: no method name found on line ``
  106. ERROR: no method name found on line ``
  107. ERROR: no method name found on line ``
  108. ERROR: no method name found on line `* @return array`
  109. ERROR: no method name found on line ``
  110. ERROR: no method name found on line ``
  111. ERROR: no method name found on line ``
  112. ERROR: no method name found on line ``
  113. ERROR: no method name found on line ``
  114. ERROR: no method name found on line `}`
  115. ERROR: no method name found on line ``
  116. ERROR: no method name found on line ``
  117. ERROR: no method name found on line ``
  118. ERROR: no method name found on line `'category' => $item['extended_info']['name'],`
  119. ERROR: no method name found on line ``
  120. ERROR: no method name found on line `'type' => 'array',`
  121. ERROR: no method name found on line `);`
  122. ERROR: no method name found on line ``
  123. ERROR: no method name found on line ``
  124. ERROR: no method name found on line ``
  125. ERROR: no method name found on line `'readonly' => true,`
  126. ERROR: no method name found on line `);`
  127. ERROR: no method name found on line `/**`
  128. ERROR: no method name found on line `);`
  129. ERROR: no method name found on line `'orders_count',`
  130. ERROR: no method name found on line `* Filter to prepare extra columns in the export item for the`
  131. ERROR: no method name found on line ``
  132. ERROR: no method name found on line `* @return array Key value pair of Column ID => Row Value.`
  133. ERROR: no method name found on line `),`
  134. ERROR: no method name found on line `'category',`
  135. ERROR: no method name found on line `);`
  136. ERROR: no method name found on line `),`
  137. ERROR: no method name found on line `),`
  138. ERROR: no method name found on line ``
  139. ERROR: no method name found on line ``
  140. ERROR: no method name found on line ``
  141. ERROR: no method name found on line `'products_count',`
  142. ERROR: no method name found on line `);`
  143. protected prepare_links( $object )
  144. ERROR: no method name found on line `),`
  145. ERROR: no method name found on line `'title' => 'report_categories',`
  146. ERROR: no method name found on line `'readonly' => true,`
  147. ERROR: no method name found on line `'readonly' => true,`
  148. ERROR: no method name found on line `'type' => 'object',`
  149. ERROR: no method name found on line `* @return array`
  150. ERROR: no method name found on line `'type' => 'array',`
  151. ERROR: no method name found on line `* @param array $item Single report item/row.`
  152. ERROR: no method name found on line `$export_columns`
  153. ERROR: no method name found on line ``
  154. ERROR: no method name found on line `*/`
  155. ERROR: no method name found on line ``
  156. ERROR: no method name found on line ``
  157. ERROR: no method name found on line ``
  158. ERROR: no method name found on line ``
  159. ERROR: no method name found on line ``
  160. ERROR: no method name found on line `);`
  161. ERROR: no method name found on line ``
  162. ERROR: no method name found on line ``
  163. ERROR: no method name found on line ``
  164. ERROR: no method name found on line `'category',`
  165. ERROR: no method name found on line `*`
  166. ERROR: no method name found on line ``
  167. ERROR: no method name found on line `'readonly' => true,`
  168. ERROR: no method name found on line `),`
  169. ERROR: no method name found on line ``
  170. ERROR: no method name found on line `'day',`
  171. ERROR: no method name found on line `'readonly' => true,`
  172. ERROR: no method name found on line ``
  173. ERROR: no method name found on line `'items_sold',`
  174. ERROR: no method name found on line `'type' => 'object',`
  175. ERROR: no method name found on line ``
  176. ERROR: no method name found on line `'type' => 'string',`
  177. ERROR: no method name found on line `'type' => 'integer',`
  178. ERROR: no method name found on line ``
  179. ERROR: no method name found on line ``
  180. ERROR: no method name found on line ``
  181. ERROR: no method name found on line ``
  182. ERROR: no method name found on line ``
  183. ERROR: no method name found on line ``
  184. ERROR: no method name found on line `* @return mixed Results from the data store.`
  185. ERROR: no method name found on line `'readonly' => true,`
  186. ERROR: no method name found on line `*/`
  187. ERROR: no method name found on line `* @param WP_REST_Request $request Request used to generate the response.`
  188. ERROR: no method name found on line ``
  189. ERROR: no method name found on line `'type' => 'array',`
  190. ERROR: no method name found on line ``
  191. ERROR: no method name found on line `'woocommerce_report_categories_prepare_export_item',`
  192. ERROR: no method name found on line `$export_columns`
  193. ERROR: no method name found on line `'title' => 'report_categories',`
  194. ERROR: no method name found on line `);`
  195. ERROR: no method name found on line ``
  196. ERROR: no method name found on line ``
  197. ERROR: no method name found on line ``
  198. ERROR: no method name found on line `}`
  199. ERROR: no method name found on line `'type' => 'integer',`
  200. ERROR: no method name found on line ``
  201. ERROR: no method name found on line ``
  202. ERROR: no method name found on line `'type' => 'string',`
  203. ERROR: no method name found on line ``
  204. ERROR: no method name found on line ``
  205. ERROR: no method name found on line ``
  206. ERROR: no method name found on line ``
  207. ERROR: no method name found on line `*/`
  208. ERROR: no method name found on line ``
  209. ERROR: no method name found on line ``
  210. ERROR: no method name found on line ``
  211. ERROR: no method name found on line ``
  212. ERROR: no method name found on line `*`
  213. ERROR: no method name found on line `),`
  214. ERROR: no method name found on line `* @return \WP_REST_Response`
  215. ERROR: no method name found on line ``
  216. ERROR: no method name found on line `'products_count' => $item['products_count'],`
  217. ERROR: no method name found on line `* Prepare links for the request.`
  218. ERROR: no method name found on line ``
  219. ERROR: no method name found on line ``
  220. ERROR: no method name found on line ``
  221. ERROR: no method name found on line ``
  222. ERROR: no method name found on line ``
  223. ERROR: no method name found on line ``
  224. ERROR: no method name found on line `);`
  225. ERROR: no method name found on line ``
  226. ERROR: no method name found on line ``
  227. ERROR: no method name found on line ``
  228. ERROR: no method name found on line `* @param mixed $report Report data item as returned from Data Store.`
  229. ERROR: no method name found on line ``
  230. ERROR: no method name found on line `$args['status_is'] = (array) $request['status_is'];`
  231. ERROR: no method name found on line `* @param WP_REST_Response $response The response object.`
  232. ERROR: no method name found on line `$args['status_is'] = (array) $request['status_is'];`
  233. ERROR: no method name found on line `$args['force_cache_refresh'] = $request['force_cache_refresh'];`
  234. ERROR: no method name found on line `$args['status_is'] = (array) $request['status_is'];`
  235. ERROR: no method name found on line ``
  236. ERROR: no method name found on line ``
  237. ERROR: no method name found on line ``
  238. ERROR: no method name found on line ``
  239. ERROR: no method name found on line ``
  240. ERROR: no method name found on line ``
  241. ERROR: no method name found on line `* @param mixed $report Report data item as returned from Data Store.`
  242. ERROR: no method name found on line ``
  243. ERROR: no method name found on line ``
  244. ERROR: no method name found on line ``
  245. ERROR: no method name found on line `'woocommerce_report_categories_prepare_export_item',`
  246. ERROR: no method name found on line `return $links;`
  247. ERROR: no method name found on line `),`
  248. ERROR: no method name found on line `return $args;`
  249. ERROR: no method name found on line `*`
  250. ERROR: no method name found on line ``
  251. ERROR: no method name found on line `$args['page'] = $request['page'];`
  252. ERROR: no method name found on line `$args['category_includes'] = (array) $request['categories'];`
  253. ERROR: no method name found on line `$args['before'] = $request['before'];`
  254. ERROR: no method name found on line `$args['before'] = $request['before'];`
  255. ERROR: no method name found on line `$args['before'] = $request['before'];`
  256. ERROR: no method name found on line `$args['per_page'] = $request['per_page'];`
  257. ERROR: no method name found on line `$args['interval'] = $request['interval'];`
  258. ERROR: no method name found on line `$args['before'] = $request['before'];`
  259. ERROR: no method name found on line `* Maps query arguments from the REST request.`
  260. ERROR: no method name found on line `$args['status_is_not'] = (array) $request['status_is_not'];`
  261. ERROR: no method name found on line `return $params;`
  262. ERROR: no method name found on line `* @return array`
  263. ERROR: no method name found on line `'year',`
  264. ERROR: no method name found on line ``
  265. ERROR: no method name found on line ``
  266. ERROR: no method name found on line ``
  267. ERROR: no method name found on line ``
  268. ERROR: no method name found on line ``
  269. ERROR: no method name found on line ``
  270. ERROR: no method name found on line ``
  271. ERROR: no method name found on line ``
  272. ERROR: no method name found on line ``
  273. ERROR: no method name found on line `);`
  274. ERROR: no method name found on line ``
  275. ERROR: no method name found on line ``
  276. ERROR: no method name found on line `$args['after'] = $request['after'];`
  277. ERROR: no method name found on line `);`
  278. ERROR: no method name found on line `),`
  279. ERROR: no method name found on line `* Prepare a report data item for serialization.`
  280. ERROR: no method name found on line `return $links;`
  281. ERROR: no method name found on line `),`
  282. ERROR: no method name found on line `* @return array`
  283. ERROR: no method name found on line `* @param \Automattic\WooCommerce\Admin\API\Reports\GenericQuery $object Object data.`
  284. ERROR: no method name found on line `* @return \WP_REST_Response`
  285. ERROR: no method name found on line `*`
  286. ERROR: no method name found on line `return $links;`
  287. ERROR: no method name found on line ``
  288. ERROR: no method name found on line `$args['status_is_not'] = (array) $request['status_is_not'];`
  289. ERROR: no method name found on line ``
  290. ERROR: no method name found on line ``
  291. ERROR: no method name found on line `'readonly' => true,`
  292. ERROR: no method name found on line ``
  293. ERROR: no method name found on line `/**`
  294. ERROR: no method name found on line `),`
  295. ERROR: no method name found on line ``
  296. ERROR: no method name found on line `*/`
  297. ERROR: no method name found on line `* @return array`
  298. ERROR: no method name found on line ``
  299. ERROR: no method name found on line `'validate_callback' => 'rest_validate_request_arg',`
  300. ERROR: no method name found on line `*`
  301. ERROR: no method name found on line ``
  302. ERROR: no method name found on line ``
  303. ERROR: no method name found on line `'readonly' => true,`
  304. ERROR: no method name found on line ``
  305. ERROR: no method name found on line `$args['after'] = $request['after'];`
  306. ERROR: no method name found on line ``
  307. ERROR: no method name found on line `* @param \Automattic\WooCommerce\Admin\API\Reports\GenericQuery $object Object data.`
  308. ERROR: no method name found on line `$args['force_cache_refresh'] = $request['force_cache_refresh'];`
  309. ERROR: no method name found on line `*/`
  310. ERROR: no method name found on line `*/`
  311. ERROR: no method name found on line `* @param array $query_args Query arguments.`
  312. ERROR: no method name found on line `*/`
  313. ERROR: no method name found on line `}`
  314. ERROR: no method name found on line `$args['interval'] = $request['interval'];`
  315. ERROR: no method name found on line `return $links;`
  316. ERROR: no method name found on line ``
  317. ERROR: no method name found on line ``
  318. ERROR: no method name found on line `*`
  319. ERROR: no method name found on line ``
  320. ERROR: no method name found on line ``
  321. ERROR: no method name found on line ``
  322. ERROR: no method name found on line `protected $rest_base = 'reports/categories';`
  323. ERROR: no method name found on line `* Filter a report returned from the API.`
  324. ERROR: no method name found on line `* Get data from `'categories'` GenericQuery.`
  325. ERROR: no method name found on line ``
  326. ERROR: no method name found on line `*/`
  327. ERROR: no method name found on line `/**`
  328. ERROR: no method name found on line `/**`
  329. ERROR: no method name found on line `* @param mixed $report Report data item as returned from Data Store.`
  330. ERROR: no method name found on line `* @param mixed $report Report data item as returned from Data Store.`
  331. ERROR: no method name found on line `$args['category_includes'] = (array) $request['categories'];`
  332. ERROR: no method name found on line ``
  333. ERROR: no method name found on line `* @return \WP_REST_Response`
  334. ERROR: no method name found on line `$args['extended_info'] = $request['extended_info'];`
  335. ERROR: no method name found on line `$args['before'] = $request['before'];`
  336. ERROR: no method name found on line `'sanitize_callback' => 'wc_string_to_bool',`
  337. ERROR: no method name found on line ``
  338. ERROR: no method name found on line `*/`
  339. ERROR: no method name found on line `'woocommerce_report_categories_prepare_export_item',`
  340. ERROR: no method name found on line ``
  341. ERROR: no method name found on line ``
  342. ERROR: no method name found on line `'sanitize_callback' => 'wp_parse_slug_list',`
  343. ERROR: no method name found on line `'category',`
  344. ERROR: no method name found on line ``
  345. ERROR: no method name found on line `'orders_count',`
  346. ERROR: no method name found on line ``
  347. ERROR: no method name found on line ``
  348. ERROR: no method name found on line `}`
  349. ERROR: no method name found on line `'woocommerce_report_categories_prepare_export_item',`
  350. ERROR: no method name found on line ``
  351. ERROR: no method name found on line `'validate_callback' => 'rest_validate_request_arg',`
  352. ERROR: no method name found on line `),`
  353. ERROR: no method name found on line `'type' => 'string',`
  354. ERROR: no method name found on line `'readonly' => true,`
  355. ERROR: no method name found on line ``
  356. ERROR: no method name found on line ``
  357. ERROR: no method name found on line ``
  358. ERROR: no method name found on line `'$schema' => 'http://json-schema.org/draft-04/schema#',`
  359. ERROR: no method name found on line `*/`
  360. ERROR: no method name found on line `),`
  361. ERROR: no method name found on line `'type' => 'object',`
  362. ERROR: no method name found on line `'type' => 'number',`
  363. ERROR: no method name found on line `'type' => 'number',`
  364. ERROR: no method name found on line `*/`
  365. ERROR: no method name found on line ``
  366. ERROR: no method name found on line ``
  367. ERROR: no method name found on line ``
  368. ERROR: no method name found on line `*`
  369. ERROR: no method name found on line `*/`
  370. ERROR: no method name found on line `}`
  371. ERROR: no method name found on line ``
  372. ERROR: no method name found on line ``
  373. ERROR: no method name found on line ``
  374. ERROR: no method name found on line ``
  375. ERROR: no method name found on line ``

Код Controller{} WC 11.3.0

class Controller extends GenericController implements ExportableInterface {

	use OrderAwareControllerTrait;

	/**
	 * Route base.
	 *
	 * @var string
	 */
	protected $rest_base = 'reports/categories';

	/**
	 * Get data from `'categories'` GenericQuery.
	 *
	 * @override GenericController::get_datastore_data()
	 *
	 * @param array $query_args Query arguments.
	 * @return mixed Results from the data store.
	 */
	protected function get_datastore_data( $query_args = array() ) {
		$query = new GenericQuery( $query_args, 'categories' );
		return $query->get_data();
	}

	/**
	 * Maps query arguments from the REST request.
	 *
	 * @param array $request Request array.
	 * @return array
	 */
	protected function prepare_reports_query( $request ) {
		$args                        = array();
		$args['before']              = $request['before'];
		$args['after']               = $request['after'];
		$args['interval']            = $request['interval'];
		$args['page']                = $request['page'];
		$args['per_page']            = $request['per_page'];
		$args['orderby']             = $request['orderby'];
		$args['order']               = $request['order'];
		$args['extended_info']       = $request['extended_info'];
		$args['category_includes']   = (array) $request['categories'];
		$args['status_is']           = (array) $request['status_is'];
		$args['status_is_not']       = (array) $request['status_is_not'];
		$args['force_cache_refresh'] = $request['force_cache_refresh'];

		return $args;
	}

	/**
	 * Prepare a report data item for serialization.
	 *
	 * @param mixed            $report  Report data item as returned from Data Store.
	 * @param \WP_REST_Request $request Request object.
	 * @return \WP_REST_Response
	 */
	public function prepare_item_for_response( $report, $request ) {
		// Wrap the data in a response object.
		$response = parent::prepare_item_for_response( $report, $request );
		$response->add_links( $this->prepare_links( $report ) );

		/**
		 * Filter a report returned from the API.
		 *
		 * Allows modification of the report data right before it is returned.
		 *
		 * @param WP_REST_Response $response The response object.
		 * @param object           $report   The original report object.
		 * @param WP_REST_Request  $request  Request used to generate the response.
		 */
		return apply_filters( 'woocommerce_rest_prepare_report_categories', $response, $report, $request );
	}

	/**
	 * Prepare links for the request.
	 *
	 * @param \Automattic\WooCommerce\Admin\API\Reports\GenericQuery $object Object data.
	 * @return array
	 */
	protected function prepare_links( $object ) {
		$links = array(
			'category' => array(
				'href' => rest_url( sprintf( '/%s/products/categories/%d', $this->namespace, $object['category_id'] ) ),
			),
		);

		return $links;
	}

	/**
	 * Get the Report's schema, conforming to JSON Schema.
	 *
	 * @return array
	 */
	public function get_item_schema() {
		$schema = array(
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
			'title'      => 'report_categories',
			'type'       => 'object',
			'properties' => array(
				'category_id'    => array(
					'description' => __( 'Category ID.', 'woocommerce' ),
					'type'        => 'integer',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
				),
				'items_sold'     => array(
					'description' => __( 'Amount of items sold.', 'woocommerce' ),
					'type'        => 'integer',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
				),
				'net_revenue'    => array(
					'description' => __( 'Total sales.', 'woocommerce' ),
					'type'        => 'number',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
				),
				'orders_count'   => array(
					'description' => __( 'Number of orders.', 'woocommerce' ),
					'type'        => 'integer',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
				),
				'products_count' => array(
					'description' => __( 'Amount of products.', 'woocommerce' ),
					'type'        => 'integer',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
				),
				'extended_info'  => array(
					'name' => array(
						'type'        => 'string',
						'readonly'    => true,
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Category name.', 'woocommerce' ),
					),
				),
			),
		);

		return $this->add_additional_fields_schema( $schema );
	}

	/**
	 * Get the query params for collections.
	 *
	 * @return array
	 */
	public function get_collection_params() {
		$params                       = parent::get_collection_params();
		$params['orderby']['default'] = 'category_id';
		$params['orderby']['enum']    = $this->apply_custom_orderby_filters(
			array(
				'category_id',
				'items_sold',
				'net_revenue',
				'orders_count',
				'products_count',
				'category',
			)
		);
		$params['interval']           = array(
			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
			'type'              => 'string',
			'default'           => 'week',
			'enum'              => array(
				'hour',
				'day',
				'week',
				'month',
				'quarter',
				'year',
			),
			'validate_callback' => 'rest_validate_request_arg',
		);
		$params['status_is']          = array(
			'description'       => __( 'Limit result set to items that have the specified order status.', 'woocommerce' ),
			'type'              => 'array',
			'sanitize_callback' => 'wp_parse_slug_list',
			'validate_callback' => 'rest_validate_request_arg',
			'items'             => array(
				'enum' => self::get_order_statuses(),
				'type' => 'string',
			),
		);
		$params['status_is_not']      = array(
			'description'       => __( 'Limit result set to items that don\'t have the specified order status.', 'woocommerce' ),
			'type'              => 'array',
			'sanitize_callback' => 'wp_parse_slug_list',
			'validate_callback' => 'rest_validate_request_arg',
			'items'             => array(
				'enum' => self::get_order_statuses(),
				'type' => 'string',
			),
		);
		$params['categories']         = array(
			'description'       => __( 'Limit result set to all items that have the specified term assigned in the categories taxonomy.', 'woocommerce' ),
			'type'              => 'array',
			'sanitize_callback' => 'wp_parse_id_list',
			'validate_callback' => 'rest_validate_request_arg',
			'items'             => array(
				'type' => 'integer',
			),
		);
		$params['extended_info']      = array(
			'description'       => __( 'Add additional piece of info about each category to the report.', 'woocommerce' ),
			'type'              => 'boolean',
			'default'           => false,
			'sanitize_callback' => 'wc_string_to_bool',
			'validate_callback' => 'rest_validate_request_arg',
		);

		return $params;
	}

	/**
	 * Get the column names for export.
	 *
	 * @return array Key value pair of Column ID => Label.
	 */
	public function get_export_columns() {
		$export_columns = array(
			'category'       => __( 'Category', 'woocommerce' ),
			'items_sold'     => __( 'Items sold', 'woocommerce' ),
			'net_revenue'    => __( 'Net Revenue', 'woocommerce' ),
			'products_count' => __( 'Products', 'woocommerce' ),
			'orders_count'   => __( 'Orders', 'woocommerce' ),
		);

		/**
		 * Filter to add or remove column names from the categories report for
		 * export.
		 *
		 * @since 1.6.0
		 */
		return apply_filters(
			'woocommerce_report_categories_export_columns',
			$export_columns
		);
	}

	/**
	 * Get the column values for export.
	 *
	 * @param array $item Single report item/row.
	 * @return array Key value pair of Column ID => Row Value.
	 */
	public function prepare_item_for_export( $item ) {
		$export_item = array(
			'category'       => $item['extended_info']['name'],
			'items_sold'     => $item['items_sold'],
			'net_revenue'    => $item['net_revenue'],
			'products_count' => $item['products_count'],
			'orders_count'   => $item['orders_count'],
		);

		/**
		 * Filter to prepare extra columns in the export item for the
		 * categories export.
		 *
		 * @since 1.6.0
		 */
		return apply_filters(
			'woocommerce_report_categories_prepare_export_item',
			$export_item,
			$item
		);
	}
}