Automattic\WooCommerce\Admin\API\Reports\Categories

Controller::get_collection_params()publicWC 1.0

Get the query params for collections.

Method of the class: Controller{}

No Hooks.

Return

Array.

Usage

$Controller = new Controller();
$Controller->get_collection_params();

Controller::get_collection_params() code WC 9.3.3

public function get_collection_params() {
	$params                       = parent::get_collection_params();
	$params['orderby']['default'] = 'category_id';
	$params['orderby']['enum']    = 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;
}