Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Created May 28, 2015 03:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save digitalchild/3b75a5ff599357f0a4b3 to your computer and use it in GitHub Desktop.
Save digitalchild/3b75a5ff599357f0a4b3 to your computer and use it in GitHub Desktop.
Vendor Commission based on Category fixed price
<?php
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 4 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order ) {
$terms = get_the_terms( $product_id, 'product_cat' );
// Loop through the categories
// It will break on the first category assigned
foreach ( $terms as $term ) {
switch ( strtolower( $term->name ) ) {
case 't-shirts':
$commission = $product_price - 12;
break;
case 'canvas':
$commission = $product_price - 10;
break;
case 'hats':
$commission = $product_price - 17;
break;
case 'hoodies':
$commission = $product_price - 26;
break;
// Some default if it fails all the above.
default:
$commission = $product_price - 2;
break;
}
}
return round( $commission, 2 );
}
Copy link

ghost commented Jun 24, 2015

Please let me know how to implement this in wcvendor local installation with latest version

@bentasm1
Copy link

Easy, just add it to your themes functions.php file. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment