Skip to content
Docs
Get RestroPress

Filter

rpress_category_sales_graph_data

Updated
On this page

Filters the data plotted in the category sales pie chart.

Runs when the Earnings by Category or Earnings by Add-on reports build their sales pie chart. The array maps each label to its total sales, already sorted from highest to lowest, with child terms and zero-sales rows left out. Reorder, trim or relabel the entries before they are drawn.

Parameters#

ParameterTypeDescription
$dataarrayAssociative array of label => total sales (number), sorted high to low.

Return value#

array. The filtered label => total sales array.

Example#

function my_top_ten_sales( $data ) {
	return array_slice( $data, 0, 10, true );
}
add_filter( 'rpress_category_sales_graph_data', 'my_top_ten_sales', 10, 1 );

Notes#

Fired from both the categories report table and the add-ons report table with the same arguments.

Source#

Applied in:

  • includes/admin/reporting/class-addons-reports-table.php (line 278), in RPRESS_Addons_Reports_Table::output_sales_graph()
  • includes/admin/reporting/class-categories-reports-table.php (line 278), in RPRESS_Categories_Reports_Table::output_sales_graph()

See also#

Was this page helpful?