Last active
September 14, 2022 11:28
-
-
Save danielbitzer/20ff4efbb7c1fefe16f8e0deaeb44775 to your computer and use it in GitHub Desktop.
[Refer A Friend] Advocate rewards based on their user role and percentage of order
This file contains hidden or 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( 'automatewoo/referrals/reward_amount', 'my_automatewoo_referral_reward_amount', 10, 3 ); | |
/** | |
* @param $reward_amount | |
* @param AW_Model_Referral_Advocate $advocate | |
* @param WC_Order $order | |
* @return mixed | |
*/ | |
function my_automatewoo_referral_reward_amount( $reward_amount, $advocate, $order ) { | |
$advocate_user = $advocate->get_user(); | |
$role = current( $advocate_user->roles ); | |
if ( $role == 'administrator' ) { | |
$reward_percentage = 50; | |
} | |
else { | |
$reward_percentage = 10; | |
} | |
return $order->get_total() * $reward_percentage / 100; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Above is percentage based amount, but is it possible to set the different fixed amount for advokat based on his role which he will earn only when customer reffered to website and purchased.
Because by default automatewoo refer a freind allow to add 1 price for advokat and 1 for person who reffered, we want to keep same settings but want to change retail price for advokat to something else then the mentioned in setting and 0 earning for customer.