Skip to content
Docs
Get RestroPress

Filter

rpress_decrease_sales_on_undo

Updated
On this page

Filters whether menu item sales counts are decreased when a purchase is undone.

Runs for each line item in rpress_undo_purchase(). Only a strict true causes rpress_decrease_purchase_count() to be called for the item; It is called with the line quantity. Return false to leave the item untouched.

Parameters#

ParameterTypeDescription
$decreaseboolDefault value; true means decrease.
$paymentRPRESS_PaymentThe payment object.
$item_idintThe menu item ID of the cart line being processed.

Return value#

bool. Return true to decrease, false to skip.

Example#

add_filter( 'rpress_decrease_sales_on_undo', 'my_keep_stats_on_undo_sales', 10, 3 );
function my_keep_stats_on_undo_sales( $decrease, $payment, $item_id ) {
	if ( 'cash_on_delivery' === $payment->gateway ) {
		return false;
	}
	return $decrease;
}

Notes#

Any value other than boolean true is treated as false.

Source#

Applied in:

  • includes/payments/functions.php (line 467), in rpress_undo_purchase()

See also#

Was this page helpful?