Use the configured reward percentage against the order subtotal, excluding discounts, fees, shipping, and tax.
Developer note:
Add custom PHP in a small custom plugin or child theme, and test it on a staging site before production. This example requires ongoing maintenance when extension APIs change.
functions.php
<?php
add_filter( 'automatewoo/referrals/reward_amount', 'my_store_referral_subtotal_reward', 10, 3 );
/**
* Calculate store credit from the referred order subtotal.
*
* @param float $reward_amount Existing reward amount.
* @param AutomateWoo\Referrals\Advocate $advocate Advocate.
* @param WC_Order $order Referred order.
* @return float
*/
function my_store_referral_subtotal_reward( $reward_amount, $advocate, $order ) {
if ( ! $order instanceof WC_Order ) {
return $reward_amount;
}
$percentage = (float) AW_Referrals()->options()->reward_amount;
return (float) $order->get_subtotal() * $percentage / 100;
}