WooCommerce Code Reference

WC_Admin_Report

Admin Report.

Extended by reports to show charts and stats in admin.

Tags
version
2.1.0

Table of Contents

$barwidth  : int
The bar width.
$chart_groupby  : string
Group chart item by day or month.
$chart_interval  : int
The chart interval.
$end_date  : int
The end date of the report.
$group_by_query  : string
Group by SQL query.
$start_date  : int
The start date of the report.
$cached_results  : array<string|int, mixed>
The list of transients.
$transients_to_update  : array<string|int, mixed>
List of transients name that have been updated and need persisting.
calculate_current_range()  : mixed
Get the current range and calculate the start and end dates.
check_current_range_nonce()  : mixed
Check nonce for current range.
get_chart_legend()  : array<string|int, mixed>
Get the legend for the main chart sidebar.
get_chart_widgets()  : array<string|int, mixed>
Get chart widgets.
get_currency_tooltip()  : string
Return currency tooltip JS based on WooCommerce currency position settings.
get_export_button()  : mixed
Get an export link if needed.
get_main_chart()  : mixed
Get the main chart.
get_order_report_data()  : mixed
Get report totals such as order totals and discount amounts.
maybe_update_transients()  : mixed
Function to update the modified transients at the end of the request.
output_report()  : mixed
Output the report.
prepare_chart_data()  : array<string|int, mixed>
Put data with post_date's into an array of times.
sales_sparkline()  : string
Prepares a sparkline to show sales in the last X days.
add_update_transients_hook()  : mixed
Init the static hooks of the class.
enable_big_selects()  : mixed
Enables big mysql selects for reports, just once for this session.
get_cached_query()  : mixed
Get the cached query result or null if it's not in the cache.
set_cached_query()  : mixed
Set the cached query result.

Properties

Methods

calculate_current_range()

Get the current range and calculate the start and end dates.

public calculate_current_range(string $current_range) : mixed
Parameters
$current_range : string

Type of range.

Return values
mixed

check_current_range_nonce()

Check nonce for current range.

public check_current_range_nonce(string $current_range) : mixed
Parameters
$current_range : string

Current range.

Tags
since
3.0.4
Return values
mixed

get_order_report_data()

Get report totals such as order totals and discount amounts.

public get_order_report_data([array<string|int, mixed> $args = array() ]) : mixed

Data example:

'_order_total' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales' )

Parameters
$args : array<string|int, mixed> = array()

arguments for the report.

Return values
mixeddepending on query_type

prepare_chart_data()

Put data with post_date's into an array of times.

public prepare_chart_data(array<string|int, mixed> $data, string $date_key, string $data_key, int $interval, string $start_date, string $group_by) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

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 : int

interval to use.

$start_date : string

start date.

$group_by : string

group by.

Return values
array<string|int, mixed>

sales_sparkline()

Prepares a sparkline to show sales in the last X days.

public sales_sparkline([int $id = '' ][, int $days = 7 ][, string $type = 'sales' ]) : string
Parameters
$id : int = ''

ID of the product to show. Blank to get all orders.

$days : int = 7

Days of stats to get.

$type : string = 'sales'

Type of sparkline to get. Ignored if ID is not set.

Return values
string

get_cached_query()

Get the cached query result or null if it's not in the cache.

protected get_cached_query(string $query_hash) : mixed
Parameters
$query_hash : string

The query hash.

Return values
mixed

set_cached_query()

Set the cached query result.

protected set_cached_query(string $query_hash, mixed $data) : mixed
Parameters
$query_hash : string

The query hash.

$data : mixed

The data to cache.

Return values
mixed