Skip to content
Docs
Get RestroPress

Filter

rpress_fooditem_decrease_earnings_amount

Updated
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#

ParameterTypeDescription
$new_amountfloatProposed new earnings total (current earnings minus the amount).
$current_earningsfloatCurrent stored earnings.
$amountint|floatAmount being subtracted.
$fooditemRPRESS_FooditemThe 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), in RPRESS_Fooditem::decrease_earnings()

See also#

Was this page helpful?