Filter
rpress_payment_stats_item_earnings
On this page
Filters the running earnings total for a menu item while it is summed across payments.
Runs in RPRESS_Payment_Stats::get_earnings when computing earnings for a single menu item. It is applied inside the loop over matching cart items in each payment, after the item's price and item fees were added. The value is a running total across all payments processed so far, not a per-item amount.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$earnings | float | Running earnings total for the menu item. |
$payment_id | int | ID of the payment being processed. |
$cart_key | int|string | Key of the item in the payment's cart details. |
$item | array | Cart item details. |
Return value#
float. The running earnings total.
Example#
function my_item_earnings( $earnings, $payment_id, $cart_key, $item ) {
return $earnings - (float) get_post_meta( $payment_id, '_my_item_adjustment', true );
}
add_filter( 'rpress_payment_stats_item_earnings', 'my_item_earnings', 10, 4 );
Notes#
Because the value accumulates, an adjustment you subtract is applied once for every matching item.
Source#
Applied in:
includes/payments/class-payment-stats.php(line 196), inRPRESS_Payment_Stats::get_earnings()
See also#
Was this page helpful?
