Created
May 15, 2023 04:08
-
-
Save MarkKevin08/c29513cc834285145ea22b8a5041a05c to your computer and use it in GitHub Desktop.
add vat over commission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add 16% VAT to vendor commission | |
add_filter( 'wcv_process_commission', 'my_wcv_commission_rate', 10, 5 ); | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment