Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Last active May 13, 2023 01:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalchild/e5fcf36860a9a8b90e42186e1c774b0c to your computer and use it in GitHub Desktop.
Save digitalchild/e5fcf36860a9a8b90e42186e1c774b0c to your computer and use it in GitHub Desktop.
Add 16% VAT to vendors commission.
<?php
// Add 16% VAT to vendor commission
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