Filter
rpress_decrease_sales_on_undo
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#
| Parameter | Type | Description |
|---|---|---|
$decrease | bool | Default value; true means decrease. |
$payment | RPRESS_Payment | The payment object. |
$item_id | int | The 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), inrpress_undo_purchase()
See also#
Was this page helpful?
