Last active
September 14, 2022 11:14
-
-
Save danielbitzer/aafc6fe3ff4b85f1170f3cd68002e9fb to your computer and use it in GitHub Desktop.
[Refer A Friend] Set store credit reward to percentage of order subtotal i.e. excluding discounts
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', 'filter_automatewoo_referrals_reward_amount', 10, 3 ); | |
/** | |
* @param float $reward_amount | |
* @param \AutomateWoo\Referrals\Advocate $advocate | |
* @param \WC_Order $order | |
* @return float | |
*/ | |
function filter_automatewoo_referrals_reward_amount( $reward_amount, $advocate, $order ){ | |
if ( ! $order ) { | |
return 0; | |
} | |
$reward_percentage = (float) AW_Referrals()->options()->reward_amount; | |
return $order->get_subtotal() * $reward_percentage / 100; // subtotal excludes all discounts, fees and shipping | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment