Filter
rpress_api_sales
On this page
Filters the recent sales data returned by the sales API endpoint.
Runs at the end of a sales request. The array has a sales key holding a list of order entries with their products and discounts. Use it to add fields or remove data from the response.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$sales | array | API response data containing the sales list. |
$api | RPRESS_API | The API object handling the request. |
Return value#
array. The sales response data.
Example#
function my_api_sales( $sales, $api ) {
$sales['generated_by'] = 'my-plugin';
return $sales;
}
add_filter( 'rpress_api_sales', 'my_api_sales', 10, 2 );
Notes#
Fired from the base API class and the v2 class with the same signature.
Source#
Applied in:
includes/api/class-rpress-api-v2.php(line 335), inRPRESS_API_V2::get_recent_sales()includes/api/class-rpress-api.php(line 1224), inRPRESS_API::get_recent_sales()
See also#
Was this page helpful?
