Control whether refunds without a valid parent order are excluded from the refunds data source.
Orphaned or broken refund records (no parent order or invalid parent) can be skipped when building refunds data. By default the filter returns true, so refunds without a valid parent are skipped. Return false to include them (e.g. for debugging or if your data has valid refunds without a loadable parent).
File: includes/classes/data-sources/WPDAI_Refunds_Internal_Data_Source.php
Context: When processing each refund; if true and the parent order is missing, the refund is skipped.
| Parameter | Type | Description |
|---|---|---|
| $skip_refunds_without_parent | bool | Whether to skip refunds that have no valid parent order (default true) |
| $refund | WC_Order_Refund | The current refund order object |
| $data_warehouse | WPDAI_Data_Warehouse | The data warehouse instance |
Type: bool
True to skip refunds without a valid parent; false to include them.
add_filter( 'wpd_alpha_insights_skip_refunds_without_parent', '__return_false' );
add_filter( 'wpd_alpha_insights_skip_refunds_without_parent', 'skip_orphan_refunds_unless_debug', 10, 3 );
function skip_orphan_refunds_unless_debug( $skip, $refund, $data_warehouse ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && current_user_can( 'manage_options' ) ) {
return false; // Include orphans when debugging
}
return $skip;
}