Skip to content

ARR Calculation

ARR is calculated by CalculatorHelper::calculate_arr(WC_Subscription $subscription): float.

Algorithm

  1. Determine the calculation start date — either:
  2. schedule_auto_reactivation if the subscription is on-hold with a future reactivation date (temporary pause).
  3. schedule_next_payment if the subscription is active.
  4. If neither applies, ARR is 0.

  5. Call DateHelper::calculate_active_weeks_from_date($date) to get the number of weeks between the start date and exactly one year from now.

  6. Divide active weeks by the billing interval (e.g. 4 weeks → interval 4 → 1 renewal per entry). Each slot becomes ['total' => $subscription->get_total()].

  7. Add one extra renewal for the renewal expected on the calculation date itself (it falls outside the weekly-slot loop).

  8. Apply the arr/calculate/renewal-totals filter so other modules (e.g. RecurringCoupons) can adjust individual renewal totals.

  9. 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 );