Hide Commission and Earnings on Order Details Page

How can we hide commission and earnings on the order details page?

Thanks,
Tom

1 Like

Thanks for the details, this is rather a bug so we’ll fix it in the next update. If there’s no commission these rows should be hidden.

When is the next update? I don’t want our Stripe developer to get confused by this…

It’s planned for this weekend, we released a new version yesterday and currently collecting feedback, there are always some minor adjustments or fixes after new features are added.

Thanks for the update and understood.

Tom

1 Like

Did we have any success with the new version and when it’s planned to be released?

Thanks,
Tom

Sorry for the delay, this requires a bit more testing, but if it’s urgent you can use this PHP snippet

add_filter(
	'woocommerce_get_order_item_totals',
	function($rows, $order){
		
		// Check order.
		if ( ! $order->get_meta( 'hp_vendor' ) ) {
			return $rows;
		}

		// Get vendor.
		$vendor = HivePress\Models\Vendor::query()->get_by_id( $order->get_meta( 'hp_vendor' ) );

		if ( ! $vendor || ( ! current_user_can( 'edit_others_posts' ) && get_current_user_id() !== $vendor->get_user__id() ) ) {
			return $rows;
		}

		// Get item.
		$item = hivepress()->helper->get_first_array_value( $order->get_items() );

		if ( ! $item ) {
			return $rows;
		}

		// Get commissions.
		$commissions = [];

		$commission_rate = floatval( $order->get_meta( 'hp_commission_rate' ) );
		$commission_fee  = floatval( $order->get_meta( 'hp_commission_fee' ) );

		if ( $item->get_meta( 'hp_commission_fee' ) && ! $order->get_total_refunded() ) {
			$commission_fee -= floatval( $item->get_meta( 'hp_commission_fee' ) );
		}

		if ( $commission_rate ) {
			$commission_text = round( ( 1 - $commission_rate ) * 100, 2 );

			if ( $commission_text ) {
				$commissions[] = $commission_text . '%';
			}
		}

		if ( $commission_fee ) {
			$commissions[] = wc_price( $commission_fee );
		}

		// Check commissions.
		if ( ! $commissions ) {
			unset($rows['commission'], $rows['profit'] );
			return $rows;
		}
		
		return $rows;
	},
	1000,
	2
);

Thanks for the temporary fix that works great until the bug fix!

-Tom

1 Like

Any news about this fix?

Please try using the code snippet above as a temporary solution, we’re already packing & testing a new version of Marketplace so it should be released within 1-2 days.

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