Skip to content
Docs
Get RestroPress

Filter

rpress_fees_set_fees

Updated
On this page

Filters the full set of cart fees before they are saved to the session.

Runs inside RPRESS_Fees::add_fee() after the new fee has been merged into the existing fees and before the array is written to the rpress_cart_fees session value. The array is keyed by fee ID. Callbacks can add, remove or alter any fee.

Parameters#

ParameterTypeDescription
$feesarrayAll fees, keyed by fee ID, including the one just added.
$fees_objectRPRESS_FeesThe RPRESS_Fees instance.

Return value#

array. The fees to store in the session.

Example#

function my_set_fees( $fees, $fees_object ) {
	// Cap every fee at 10.00.
	foreach ( $fees as $key => $fee ) {
		if ( (float) $fee['amount'] > 10 ) {
			$fees[ $key ]['amount'] = '10.00';
		}
	}
	return $fees;
}
add_filter( 'rpress_fees_set_fees', 'my_set_fees', 10, 2 );

Notes#

Only fires when a fee is added, not when one is removed.

Source#

Applied in:

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

See also#

Was this page helpful?