Skip to content
Docs
Get RestroPress

Filter

rpress_fees_get_fees

Updated
On this page

Filters the list of fees returned by RPRESS_Fees::get_fees().

Runs after the session fees have been narrowed by type, menu item and price ID and after fees that belong to menu items not in the cart have been dropped. If no fees remain, an empty array is passed. Use it to hide or inject fees when they are read, for example in the cart or at checkout.

Parameters#

ParameterTypeDescription
$feesarrayFees matching the request, keyed by fee ID, or an empty array.
$fees_objectRPRESS_FeesThe RPRESS_Fees instance.

Return value#

array. The fees to return.

Example#

function my_get_fees( $fees, $fees_object ) {
	// Hide fees with a zero amount.
	foreach ( $fees as $key => $fee ) {
		if ( 0.0 === (float) $fee['amount'] ) {
			unset( $fees[ $key ] );
		}
	}
	return $fees;
}
add_filter( 'rpress_fees_get_fees', 'my_get_fees', 10, 2 );

Notes#

Runs on every read of the fees, which can happen many times per request.

Source#

Applied in:

  • includes/class-rpress-fees.php (line 202), in RPRESS_Fees::get_fees()

See also#

Was this page helpful?