ARR Calculation¶
ARR is calculated by CalculatorHelper::calculate_arr(WC_Subscription $subscription): float.
Algorithm¶
- Determine the calculation start date — either:
schedule_auto_reactivationif the subscription is on-hold with a future reactivation date (temporary pause).schedule_next_paymentif the subscription is active.-
If neither applies, ARR is 0.
-
Call
DateHelper::calculate_active_weeks_from_date($date)to get the number of weeks between the start date and exactly one year from now. -
Divide active weeks by the billing interval (e.g. 4 weeks → interval 4 → 1 renewal per entry). Each slot becomes
['total' => $subscription->get_total()]. -
Add one extra renewal for the renewal expected on the calculation date itself (it falls outside the weekly-slot loop).
-
Apply the
arr/calculate/renewal-totalsfilter so other modules (e.g.RecurringCoupons) can adjust individual renewal totals. -
Sum all totals → ARR.
Filter hooks¶
// Modify calculation arguments
add_filter( 'arr/calculate/args', function( array $args, WC_Subscription $sub ): array {
// $args keys: total, data, interval, calculate_from_date
return $args;
}, 10, 2 );
// Modify projected renewal totals
add_filter( 'arr/calculate/renewal-totals', function( array $renewals, array $args, WC_Subscription $sub ): array {
// Each entry: ['total' => float]
return $renewals;
}, 10, 3 );