Created
April 21, 2017 15:31
-
-
Save mircian/ecc26425e29955f7b36b0aa5e59e8804 to your computer and use it in GitHub Desktop.
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
<?php | |
add_filter('wcv_commission_rate', 'm_commission_update', 20, 5); | |
/** | |
* @param $commission | |
* @param $product_id | |
* @param $product_price | |
* @param $order WC_Order | |
* @param $qty | |
* | |
* @return float | |
*/ | |
function m_commission_update($commission, $product_id, $product_price, $order, $qty) { | |
$countries = array('US', 'UK'); | |
$author = WCV_Vendors::get_vendor_from_product( $product_id ); | |
if ( WCV_Vendors::is_vendor( $author ) ) { | |
// check the order location | |
if ( in_array($order->get_billing_country(), $countries) ) { | |
// the commission you want to add - switch to whatever logic fits | |
$card_commission_rate = 5; | |
// add the contry specific commission | |
$card_commission = $product_price * ( intval( $card_commission_rate ) / 100 ); | |
$card_commission = round( $card_commission, 2 ); | |
// notice the + - add to the actual commission so they get more money | |
$commission += $card_commission; | |
} | |
} | |
return $commission; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment