Created
March 30, 2017 12:13
-
-
Save vovadocent/e4b6fa5e3d7c4d43da59c70ddafab978 to your computer and use it in GitHub Desktop.
Woo export CSV - add custom fields
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 | |
////// woo export add custom fields ////// | |
// add custom column headers | |
function wc_csv_export_modify_column_headers( $column_headers ) { | |
$new_headers = array( | |
'delivery_name' => 'Location', | |
'odel_date' => 'Date', | |
); | |
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( | |
'delivery_name' => get_post(get_field('delivery_name', $order->id))->post_title, | |
'odel_date' => get_field('odel_date', $order->id), | |
); | |
return array_merge( $order_data, $custom_data ); | |
} | |
add_filter( 'wc_customer_order_csv_export_order_row', 'wc_csv_export_modify_row_data', 10, 2 ); | |
///// end of woo export custom fields //// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment