Skip to content
Docs
Get RestroPress

Filter

rpress_api_sales

Updated
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#

ParameterTypeDescription
$salesarrayAPI response data containing the sales list.
$apiRPRESS_APIThe 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), in RPRESS_API_V2::get_recent_sales()
  • includes/api/class-rpress-api.php (line 1224), in RPRESS_API::get_recent_sales()

See also#

Was this page helpful?