WC_Admin_Reports::get_reports()public staticWC 1.0

Returns the definitions for the reports to show in admin.

Method of the class: WC_Admin_Reports{}

Return

Array.

Usage

$result = WC_Admin_Reports::get_reports();

WC_Admin_Reports::get_reports() code WC 9.7.1

public static function get_reports() {
	$reports = array(
		'orders'    => array(
			'title'   => __( 'Orders', 'woocommerce' ),
			'reports' => array(
				'sales_by_date'     => array(
					'title'       => __( 'Sales by date', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'sales_by_product'  => array(
					'title'       => __( 'Sales by product', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'sales_by_category' => array(
					'title'       => __( 'Sales by category', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'coupon_usage'      => array(
					'title'       => __( 'Coupons by date', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'downloads'         => array(
					'title'       => __( 'Customer downloads', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
			),
		),
		'customers' => array(
			'title'   => __( 'Customers', 'woocommerce' ),
			'reports' => array(
				'customers'     => array(
					'title'       => __( 'Customers vs. guests', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'customer_list' => array(
					'title'       => __( 'Customer list', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
			),
		),
		'stock'     => array(
			'title'   => __( 'Stock', 'woocommerce' ),
			'reports' => array(
				'low_in_stock' => array(
					'title'       => __( 'Low in stock', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'out_of_stock' => array(
					'title'       => __( 'Out of stock', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'most_stocked' => array(
					'title'       => __( 'Most stocked', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
			),
		),
	);

	if ( wc_tax_enabled() ) {
		$reports['taxes'] = array(
			'title'   => __( 'Taxes', 'woocommerce' ),
			'reports' => array(
				'taxes_by_code' => array(
					'title'       => __( 'Taxes by code', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
				'taxes_by_date' => array(
					'title'       => __( 'Taxes by date', 'woocommerce' ),
					'description' => '',
					'hide_title'  => true,
					'callback'    => array( __CLASS__, 'get_report' ),
				),
			),
		);
	}

	/**
	 * Filter the list and add reports to the legacy _WooCommerce > Reports_.
	 *
	 * Array items should be in the format of
	 *
	 * $reports['automatewoo'] = array(
	 *     'title'   => 'AutomateWoo',
	 *     'reports' => array(
	 *         'runs_by_date' => array(
	 *             'title'       => __( 'Workflow Runs', 'automatewoo' ),
	 *             'description' => '',
	 *             'hide_title'  => false,
	 *             'callback'    => array( $this, 'get_runs_by_date' ),
	 *         ),
	 *         // ...
	 *     ),
	 * );
	 *
	 * This filter has a colliding name with the one in Automattic\WooCommerce\Admin\API\Reports\Controller.
	 * To make sure your code runs in the context of the legacy _WooCommerce > Reports_ screen, and not the REST endpoint,
	 * use the following:
	 *
	 * add_filter( 'woocommerce_admin_reports',
	 *     function( $reports ) {
	 *         if ( is_admin() ) {
	 *             // ...
	 *
	 * @param array $reports The associative array of reports.
	 */
	$reports = apply_filters( 'woocommerce_admin_reports', $reports );
	$reports = apply_filters( 'woocommerce_reports_charts', $reports ); // Backwards compatibility.

	foreach ( $reports as $key => &$report_group ) {
		if ( isset( $report_group['charts'] ) ) {
			$report_group['reports'] = $report_group['charts'];
		}

		// Silently ignore reports given for the filter in Automattic\WooCommerce\Admin\API\Reports\Controller.
		if ( ! isset( $report_group['reports'] ) ) {
			unset( $reports[ $key ] );
			continue;
		}

		foreach ( $report_group['reports'] as &$report ) {
			if ( isset( $report['function'] ) ) {
				$report['callback'] = $report['function'];
			}
		}
	}

	return $reports;
}