Wpd Alpha Insights Refund Ids To Skip

Alpha Insights Documentation

Docs Navigation

Filter: wpd_alpha_insights_refund_ids_to_skip

Specify refund IDs to exclude from the refunds data source. Refunds whose ID is in the returned array are skipped during processing.

Description

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.

Location

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.

Parameters

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

Return

Type: array

Array of refund IDs (integers) to skip. If $refund->get_id() is in this array, the refund is skipped.

Example Usage

Skip refunds from a specific gateway

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;
}

Skip specific refund IDs from options

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;
}

Related

Got A Question?

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Alpha Insights

Alpha Insights

The World's Most Advanced WooCommerce Profit Reporting Engine

5/5 – Trustpilot

Alpha Insights