Created
February 6, 2014 03:28
-
-
Save woogist/8837975 to your computer and use it in GitHub Desktop.
WooCommerce Customer/Order CSV Export: Add additional columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add custom column headers | |
function wc_csv_export_modify_column_headers( $column_headers ) { | |
$new_headers = array( | |
'column_1' => 'Column 1', | |
'column_2' => 'Column 2', | |
// add other column headers here in the format column_key => Column Name | |
); | |
return array_merge( $column_headers, $new_headers ); | |
} | |
add_filter( 'wc_customer_order_csv_export_order_headers', 'wc_csv_export_modify_column_headers' ); | |
// set the data for each for custom columns | |
function wc_csv_export_modify_row_data( $order_data, $order ) { | |
$custom_data = array( | |
'column_1' => get_post_meta( $order->id, 'some_meta_key', true ), | |
'column_2' => get_post_meta( $order->id, 'some_other_meta_key', true ), | |
// add other row data here in the format column_key => data | |
); | |
return array_merge( $order_data, $custom_data ); | |
} | |
add_filter( 'wc_customer_order_csv_export_order_row', 'wc_csv_export_modify_row_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mikeeman2000, did you ever figure that out? I'm looking to do the same.