I'd like to add a filter to Woocommerce product export to add columns but I'd like to add 5 columns using the same hook.
Is it possible to pass the hook name into the filter to allow me to determine which column the data is returned to?
For example, I want to run the following to populate 5 columns using same function (add_export_data) but the returned value would have to be determined by the hook name (containing the col number).
add_filter( 'woocommerce_product_export_product_column_val1', 'add_export_data', 10, 2 );
add_filter( 'woocommerce_product_export_product_column_val2', 'add_export_data', 10, 2 );
add_filter( 'woocommerce_product_export_product_column_val3', 'add_export_data', 10, 2 );
add_filter( 'woocommerce_product_export_product_column_val4', 'add_export_data', 10, 2 );
add_filter( 'woocommerce_product_export_product_column_val5', 'add_export_data', 10, 2 );
So ideally the function would be able to determine the hook name and then choose the relevant data to return as the value.
Thanks
From the 3rd argument, you can get the column ID then you can return the value conditionally.
Here is an example code.