1. Home
  2. WC Vendors Pro
  3. Code Snippets
  4. Add Tax to Vendor Commission

Add Tax to Vendor Commission

In some parts of the world you will need to add VAT to a commission that you provide a vendor. The following code snippet will add a 16% VAT to the vendor commission. 

 

<?php 

// Add 16% VAT to vendor commission 
// Change the 0.16 $vat_fee amount to the VAT you require
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 5 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $qty ) {

	$vat_fee = 0.16;
	$marketplace_split = $product_price - $commission; 
	$vat = $marketplace_split * $vat_fee;
	$commission -= $vat; 

	// if there is a negative number then make it 0; 
	if ( $commission < 0 ) $commission = 0;

	// Round commission so it doesn't break gateways
	$commission = round( $commission, 2 );

	// Return commission 
	return $commission;
}

filters

Updated on November 17, 2020

Was this article helpful?