woocommerce_analytics_(field) filter-hookWC 1.0

Filter the IDs before retrieving report data.

Allows filtering of the objects included or excluded from reports.

Usage

add_filter( 'woocommerce_analytics_(field)', 'wp_kama_woocommerce_analytics_field_filter', 10, 4 );

/**
 * Function for `woocommerce_analytics_(field)` filter-hook.
 * 
 * @param array  $ids        List of object Ids.
 * @param array  $query_args The original arguments for the request.
 * @param string $field      The object type.
 * @param string $context    The data store context.
 *
 * @return array
 */
function wp_kama_woocommerce_analytics_field_filter( $ids, $query_args, $field, $context ){

	// filter...
	return $ids;
}
$ids(array)
List of object Ids.
$query_args(array)
The original arguments for the request.
$field(string)
The object type.
$context(string)
The data store context.

Where the hook is called

DataStore::get_filtered_ids()
woocommerce_analytics_(field)
DataStore::get_filtered_ip_addresses()
woocommerce_analytics_(field)
woocommerce/src/Admin/API/Reports/DataStore.php 1443
$ids = apply_filters( 'woocommerce_analytics_' . $field, $ids, $query_args, $field, $this->context );
woocommerce/src/Admin/API/Reports/Downloads/DataStore.php 225
$ip_addresses = apply_filters( 'woocommerce_analytics_' . $field, $ip_addresses, $query_args, $field, $this->context );

Where the hook is used in WooCommerce

woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php 42
add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] );
woocommerce/src/Admin/API/Reports/Coupons/DataStore.php 69
add_action( 'woocommerce_analytics_delete_order_stats', array( __CLASS__, 'sync_on_order_delete' ), 5 );
woocommerce/src/Admin/API/Reports/Customers/DataStore.php 87
add_action( 'woocommerce_analytics_delete_order_stats', array( __CLASS__, 'sync_on_order_delete' ), 15, 2 );
woocommerce/src/Admin/API/Reports/Products/DataStore.php 103
add_action( 'woocommerce_analytics_delete_order_stats', array( __CLASS__, 'sync_on_order_delete' ), 10 );
woocommerce/src/Admin/API/Reports/Products/Stats/Controller.php 51
add_filter( 'woocommerce_analytics_products_stats_select_query', array( $this, 'set_default_report_data' ) );
woocommerce/src/Admin/API/Reports/Taxes/DataStore.php 83
add_action( 'woocommerce_analytics_delete_order_stats', array( __CLASS__, 'sync_on_order_delete' ), 15 );
woocommerce/src/Admin/API/Reports/Taxes/Stats/Controller.php 38
add_filter( 'woocommerce_analytics_taxes_stats_select_query', array( $this, 'set_default_report_data' ) );
woocommerce/src/Admin/API/Reports/Variations/Stats/Controller.php 49
add_filter( 'woocommerce_analytics_variations_stats_select_query', array( $this, 'set_default_report_data' ) );