Skip to content
Docs
Get RestroPress

Filter

rpress_fees_add_fee

Updated
On this page

Filters a single fee's arguments before it is stored in the cart session.

Runs inside RPRESS_Fees::add_fee() after the arguments have been normalised (defaults applied, amount sanitised and formatted, no_tax forced to true for negative amounts). The array holds the keys amount, label, no_tax, type, fooditem_id and price_id. Only the fee being added is filtered here; use rpress_fees_set_fees to see all fees.

Parameters#

ParameterTypeDescription
$argsarrayFee arguments: amount, label, no_tax, type, fooditem_id, price_id.
$feesRPRESS_FeesThe RPRESS_Fees instance.

Return value#

array. The fee arguments to store.

Example#

function my_fee_args( $args, $fees ) {
	// Never charge tax on fees labelled 'Service charge'.
	if ( 'Service charge' === $args['label'] ) {
		$args['no_tax'] = true;
	}
	return $args;
}
add_filter( 'rpress_fees_add_fee', 'my_fee_args', 10, 2 );

Source#

Applied in:

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

See also#

Was this page helpful?