Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created September 23, 2015 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bentasm1/2c4ebbd74f65166fc78d to your computer and use it in GitHub Desktop.
Save bentasm1/2c4ebbd74f65166fc78d to your computer and use it in GitHub Desktop.
WC Vendors - One commission rate for regular products, one for downloadable products
/* WC Vendors - 40% commission on regular products, 50% commission on downloadable products */
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 4 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order ) {
$downloadable = get_post_meta ($product_id, '_downloadable', true); // Check if product is a download
if ( $downloadable == "yes" ) {
$commission = $product_price * .50;
$commission = round( $commission, 2 );
return $commission;
} else {
$commission = $product_price * .40;
$commission = round( $commission, 2 );
return $commission;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment