Filter
rpress_fooditem_decrease_earnings_amount
On this page
Filters the new earnings total before a menu item's earnings are decreased.
Runs in RPRESS_Fooditem::decrease_earnings() before the _rpress_fooditem_earnings meta is written. The first value is the current earnings minus the amount. It only runs when the current earnings are greater than zero.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$new_amount | float | Proposed new earnings total (current earnings minus the amount). |
$current_earnings | float | Current stored earnings. |
$amount | int|float | Amount being subtracted. |
$fooditem | RPRESS_Fooditem | The menu item object. |
Return value#
float. The earnings total to store.
Example#
function my_decrease_earnings_amount( $new_amount, $current_earnings, $amount, $fooditem ) {
// Never store negative earnings.
return max( 0, (float) $new_amount );
}
add_filter( 'rpress_fooditem_decrease_earnings_amount', 'my_decrease_earnings_amount', 10, 4 );
Source#
Applied in:
includes/class-rpress-fooditem.php(line 530), inRPRESS_Fooditem::decrease_earnings()
See also#
Was this page helpful?
