Created
September 23, 2015 00:47
-
-
Save bentasm1/2c4ebbd74f65166fc78d to your computer and use it in GitHub Desktop.
WC Vendors - One commission rate for regular products, one for downloadable products
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
/* 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