Home / Admin / Add Tax to Vendor Commission
Duplicate Snippet

Embed Snippet on Your Site

Add Tax to Vendor Commission

Code Preview
php
<?php
<?php 
// Add 16% VAT to vendor commission 
add_filter( 'wcvendors_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;
}

Comments

Add a Comment