WooCommerce Code Reference

WC_Report_Coupon_Usage extends WC_Admin_Report

WC_Report_Coupon_Usage

Extended by reports to show charts and stats in admin.

Tags
author

WooThemes

category

Admin

version
2.1.0

Table of Contents

$barwidth  : int
The bar width.
$chart_colours  : array
Chart colors.
$chart_groupby  : string
Group chart item by day or month.
$chart_interval  : int
The chart interval.
$coupon_codes  : array
Coupon codes.
$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
$transients_to_update  : array
__construct()  : mixed
Constructor.
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.
coupons_widget()  : mixed
Output coupons widget.
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()  : mixed
Output an export link.
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
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
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 $args = array() ]) : mixed

Data example:

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

Parameters
$args : array = array()
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 $data, string $date_key, string $data_key, int $interval, string $start_date, string $group_by) : array
Parameters
$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 : int
$start_date : string
$group_by : string
Return values
array

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