Specify refund IDs to exclude from the refunds data source. Refunds whose ID is in the returned array are skipped during processing.
When building refunds data, the source loops over refund orders. For each refund it calls this filter; if the current refund ID is in the returned array, that refund is skipped. Use this to exclude test refunds, system-generated refunds, or refunds that should not affect reporting.
File: includes/classes/data-sources/WPDAI_Refunds_Internal_Data_Source.php
Context: Inside the refund processing loop, before the refund is included in the data.
| Parameter | Type | Description |
|---|---|---|
| $refund_ids_to_skip | array | Array of refund IDs to skip (default empty). Add the current refund ID or others to exclude them. |
| $refund | WC_Order_Refund | The current refund order object |
| $data_warehouse | WPDAI_Data_Warehouse | The data warehouse instance |
Type: array
Array of refund IDs (integers) to skip. If $refund->get_id() is in this array, the refund is skipped.
add_filter( 'wpd_alpha_insights_refund_ids_to_skip', 'skip_test_gateway_refunds', 10, 3 );
function skip_test_gateway_refunds( $refund_ids_to_skip, $refund, $data_warehouse ) {
if ( is_a( $refund, 'WC_Order_Refund' ) ) {
$payment_method = $refund->get_payment_method();
if ( $payment_method === 'test_gateway' ) {
$refund_ids_to_skip[] = $refund->get_id();
}
}
return $refund_ids_to_skip;
}
add_filter( 'wpd_alpha_insights_refund_ids_to_skip', 'skip_configured_refund_ids', 10, 3 );
function skip_configured_refund_ids( $refund_ids_to_skip, $refund, $data_warehouse ) {
$ids = get_option( 'my_excluded_refund_ids', array() );
if ( is_array( $ids ) ) {
$refund_ids_to_skip = array_merge( $refund_ids_to_skip, array_map( 'absint', $ids ) );
}
return $refund_ids_to_skip;
}