Filter
rpress_api_stats_sales
On this page
Filters the sales statistics returned by the stats API endpoint.
Runs in RPRESS_API::get_stats() when the request type is 'sales' and no error was produced. The array is keyed by 'sales' and holds either the default totals or the figures for the requested menu item or date range. Use it to append extra figures or reshape the response.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$sales | array | Sales statistics keyed by 'sales'. |
$this | RPRESS_API | The API instance handling the request. |
Return value#
array. The sales statistics to return.
Example#
function my_api_stats_sales( $sales, $api ) {
$sales['generated_at'] = gmdate( 'c' );
return $sales;
}
add_filter( 'rpress_api_stats_sales', 'my_api_stats_sales', 10, 2 );
Notes#
Error responses (for example an unknown menu item) return before this filter runs.
Source#
Applied in:
includes/api/class-rpress-api.php(line 1035), inRPRESS_API::get_stats()
See also#
Was this page helpful?
