How can I cap the amount of fees? (ex: 5% fees but to a maximum a $200)

The market my marketplace is built for often sees transactions of several thousands dollars. I currently set a 5% service fee for buyers via the Hivepress settings. However, since payments can be huge, the fees can sometimes amount to a ridiculously high $500 or even over $1000. I do not want that to happen.

There are two solutions to this:

  • Cap the fees to a maximum of $200
  • Add a variable fee rate (example: 5% fees until $1000 and then 2.5% for bigger amounts)

Can one of the solutions be implemented into Hivepress? If yes, could you please show me how?
Thank you very much.


Unfortunately, this version has no such feature, but thanks for your suggestion; we’ll consider adding this feature.

I worked around it by applying a discount that cancels fees over the cap.
Here’s the code:

add_action('woocommerce_cart_calculate_fees', function( $cart ) {
	if ( !isset( $cart ) || ( is_admin() && !defined('DOING_AJAX'))) {

	foreach ( $cart->get_cart() as $cart_item ) {
		//get price
		$amount = floatval( $cart->get_subtotal() );
		if ( isset( $cart_item['hp_price_change'] ) && isset( $cart_item['quantity'] ) && ! get_option( 'hp_listing_discount_extras', true ) ) {
			$amount -= $cart_item['hp_price_change'] * $cart_item['quantity'];
		//original service fee percentage
		$fee = 5;
		$cap = 450;
		//calculate fee amount
		$fee_amount = ( $fee * $amount ) / 100;		
		//check if amount is over the 450 cap
		if( $fee_amount > $cap ){
			//calculate discount
			$reduced_fee_amount = $fee_amount - $cap;
			//set discount
			$cart->add_fee( 'Fair Fee Reduction*', -$reduced_fee_amount);
			//original fee slug
			$original_fee_slug = 'service-fee-5';
			//fix to prevent service fees form changing after new calculations.
			foreach ( $cart->get_fees() as $fee_item ) {
				if( $fee_item->id === $original_fee_slug ){
					$fee_item->amount = $fee_amount;
1 Like


Thanks for sharing the solution, I think it will be useful for our community.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.