Wpd Alpha Insights Data Source Expenses

Alpha Insights Documentation

Docs Navigation

Filter: wpd_alpha_insights_data_source_expenses

Filter the expenses entity data returned by the Expenses data source before it is stored in the data warehouse.

Description

After the expenses data source builds its data structure (totals, data_by_date, data_table, etc.), this filter is applied. You can modify or add metrics, adjust totals, or alter time-series data. The data warehouse then stores the returned value for the expenses entity.

Location

File: includes/classes/data-sources/pro/WPDAI_Expenses_Data_Source.php

Context: When returning expense data from the data source.

Parameters

Parameter Type Description
$expense_data array Expenses data structure (totals, categorized_data, data_table, data_by_date, total_db_records, etc.)
$data_warehouse WPDAI_Data_Warehouse The data warehouse instance (for date range, filters, or other entity data)

Return

Type: array

The (possibly modified) expenses data structure.

Example Usage

Add a custom total

add_filter( 'wpd_alpha_insights_data_source_expenses', 'add_expense_custom_total', 10, 2 );
function add_expense_custom_total( $expense_data, $data_warehouse ) {
    if ( isset( $expense_data['totals'] ) && is_array( $expense_data['totals'] ) ) {
        $expense_data['totals']['my_custom_total'] = 100.00;
    }
    return $expense_data;
}

Related

  • Other data source filters: wpd_alpha_insights_data_source_sales, wpd_alpha_insights_data_source_store_profit, wpd_alpha_insights_data_source_analytics, wpd_alpha_insights_data_source_refunds, etc.

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