Skip to content
Docs
Get RestroPress

Filter

rpress_api_products_product

Updated
On this page

Filters the data array built for a single menu item in the products API response.

Runs at the end of RPRESS_API::get_product_data(), once for each menu item returned by the products endpoint. The array holds the 'info', 'stats', 'pricing' and, for users allowed to view sensitive data, 'notes' sections. Add or remove keys to change what API clients receive for each menu item.

Parameters#

ParameterTypeDescription
$productarrayMenu item data with 'info' (id, slug, title, link, thumbnail and so on), optional 'stats', 'pricing' and optional 'notes'.

Return value#

array. The menu item data to include in the API response.

Example#

function my_api_product_permalink( $product ) {
	if ( ! empty( $product['info']['id'] ) ) {
		$product['info']['permalink'] = get_permalink( $product['info']['id'] );
	}
	return $product;
}
add_filter( 'rpress_api_products_product', 'my_api_product_permalink', 10, 1 );

Notes#

The 'stats' section is only present when the requesting user has the view_shop_reports capability (or the request is an override), and 'notes' only with view_shop_sensitive_data.

Source#

Applied in:

  • includes/api/class-rpress-api.php (line 918), in RPRESS_API::get_product_data()
  • includes/class-rpress-api.php (line 661), in RPRESS_API::get_product_data()

See also#

Was this page helpful?