Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
Last active September 14, 2022 11:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbitzer/aafc6fe3ff4b85f1170f3cd68002e9fb to your computer and use it in GitHub Desktop.
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
<?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