Filter
rpress_payment_stats_earnings_total
On this page
Filters the summed payment totals before taxes are subtracted in get_earnings.
Runs in RPRESS_Payment_Stats::get_earnings after the _rpress_payment_total meta of the matching payments has been summed with a database query. The tax total is subtracted from the filtered value afterwards when taxes are excluded. The result is cached for an hour.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$total_earnings | string|null | Sum of the payment totals as returned by the database, or null if none. |
$sales | int[] | IDs of the payments included in the sum. |
$args | array | The (filtered) query arguments used to find the payments. |
Return value#
float|string|null. The total to use.
Example#
function my_earnings_total( $total_earnings, $sales, $args ) {
$excluded = 0.0;
foreach ( $sales as $payment_id ) {
$excluded += (float) get_post_meta( $payment_id, '_my_non_revenue_amount', true );
}
return (float) $total_earnings - $excluded;
}
add_filter( 'rpress_payment_stats_earnings_total', 'my_earnings_total', 10, 3 );
Source#
Applied in:
includes/payments/class-payment-stats.php(line 134), inRPRESS_Payment_Stats::get_earnings()
See also#
Was this page helpful?
