When downloading a detailed CSV, how can I add an extra column?

A PHP developer can do this by using the hooks built-in to the plugin. We assume that the desired column has been stored in your database as an ‘order meta’ item. (If it is not, then you will need more complex processing). Below is a code example which takes an order meta item with key “PayPal Transaction Fee” and adds it to a new “PayPal Fee” column in the CSV. A developer can use and customise this example to achieve the desired result.

// Make sure that the order meta field 'PayPal Transaction Fee' is fetched from the database when selecting data for the report.
add_filter('wc_eu_vat_compliance_report_meta_fields', 'my_wc_eu_vat_compliance_report_meta_fields', 10, 2);
function my_wc_eu_vat_compliance_report_meta_fields($fields, $print_as_csv) {
return $print_as_csv ? $fields.", 'PayPal Transaction Fee'" : $fields;

// Give the order meta field 'PayPal Transaction Fee' the (internal) key 'pp_fee'
add_filter('wc_eu_vat_compliance_get_report_results_store_key', 'my_wc_eu_vat_compliance_get_report_results_store_key', 10, 2);
function my_wc_eu_vat_compliance_get_report_results_store_key($store, $res) {
return ('PayPal Transaction Fee' == $res->meta_key) ? 'pp_fee' : $store;

// Add a column header 'PayPal Fee' to the spreadsheet
add_filter('wc_eu_vat_compliance_csv_header_columns', 'my_wc_eu_vat_compliance_csv_header_columns');
function my_wc_eu_vat_compliance_csv_header_columns($columns) {
$columns[] = 'PayPal Fee';
return $columns;

// For the 'PayPal Fee' column, insert the value that we fetched earlier (pp_fee)
add_filter('wc_eu_vat_compliance_csv_data_entries', 'my_wc_eu_vat_compliance_csv_data_entries', 10, 3);
function my_wc_eu_vat_compliance_csv_data_entries($data, $order_id, $order) {
$data['PayPal Fee'] = isset($order['pp_fee']) ? $order['pp_fee'] : '';
return $data;

Posted in: WooCommerce EU/UK VAT Compliance