PHP Class WC_Admin_Report

Extended by reports to show charts and stats in admin.
Author: WooThemes
Datei anzeigen Open project: woocommerce/woocommerce Class Usage Examples

Public Properties

Property Type Description
$barwidth integer The bar width.
$chart_groupby string Group chart item by day or month.
$chart_interval integer The chart interval.
$end_date The end date of the report.
$group_by_query string Group by SQL query.
$start_date The start date of the report.

Public Methods

Method Description
calculate_current_range ( string $current_range ) Get the current range and calculate the start and end dates.
get_chart_legend ( ) : array Get the legend for the main chart sidebar.
get_chart_widgets ( ) : array Get chart widgets.
get_currency_tooltip ( ) : string Return currency tooltip JS based on WooCommerce currency position settings.
get_export_button ( ) Get an export link if needed.
get_main_chart ( ) : string Get the main chart.
get_order_report_data ( array $args = [] ) : mixed Get report totals such as order totals and discount amounts.
output_report ( ) Output the report.
prepare_chart_data ( array $data, string $date_key, string $data_key, integer $interval, string $start_date, string $group_by ) : array Put data with post_date's into an array of times.
sales_sparkline ( integer $id = '', integer $days = 7, string $type = 'sales' ) : string Prepares a sparkline to show sales in the last X days.

Method Details

calculate_current_range() public method

Get the current range and calculate the start and end dates.
public calculate_current_range ( string $current_range )
$current_range string

get_chart_legend() public method

Get the legend for the main chart sidebar.
public get_chart_legend ( ) : array
return array

get_chart_widgets() public method

Get chart widgets.
public get_chart_widgets ( ) : array
return array

get_currency_tooltip() public method

Return currency tooltip JS based on WooCommerce currency position settings.
public get_currency_tooltip ( ) : string
return string

get_export_button() public method

Get an export link if needed.
public get_export_button ( )

get_main_chart() public method

Get the main chart.
public get_main_chart ( ) : string
return string

get_order_report_data() public method

Data example: '_order_total' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales' )
public get_order_report_data ( array $args = [] ) : mixed
$args array
return mixed depending on query_type

output_report() public method

Output the report.
public output_report ( )

prepare_chart_data() public method

Put data with post_date's into an array of times.
public prepare_chart_data ( array $data, string $date_key, string $data_key, integer $interval, string $start_date, string $group_by ) : array
$data array array of your data
$date_key string key for the 'date' field. e.g. 'post_date'
$data_key string key for the data you are charting
$interval integer
$start_date string
$group_by string
return array

sales_sparkline() public method

Prepares a sparkline to show sales in the last X days.
public sales_sparkline ( integer $id = '', integer $days = 7, string $type = 'sales' ) : string
$id integer ID of the product to show. Blank to get all orders.
$days integer Days of stats to get.
$type string Type of sparkline to get. Ignored if ID is not set.
return string

Property Details

$barwidth public_oe property

The bar width.
public int $barwidth
return integer

$chart_groupby public_oe property

Group chart item by day or month.
public string $chart_groupby
return string

$chart_interval public_oe property

The chart interval.
public int $chart_interval
return integer

$end_date public_oe property

The end date of the report.
public $end_date

$group_by_query public_oe property

Group by SQL query.
public string $group_by_query
return string

$start_date public_oe property

The start date of the report.
public $start_date