Skip to content

Instantly share code, notes, and snippets.

  • Save tamarazuk/68aa8cfde324091b0054 to your computer and use it in GitHub Desktop.
Save tamarazuk/68aa8cfde324091b0054 to your computer and use it in GitHub Desktop.
<?php
// rename a column
function wc_csv_export_rename_column( $column_headers ) {
// rename the order_notes column to notes
// make sure to not change the key (`order_notes`) in this case
// as this matches the column to the relevant data
// simply change the value of the array to change the column header that's exported
$column_headers['order_notes'] = 'Notes';
return $column_headers;
}
add_filter( 'wc_customer_order_csv_export_order_headers', 'wc_csv_export_rename_column' );
// remove a column
function wc_csv_export_remove_column( $column_headers ) {
// the list of column keys can be found in class-wc-customer-order-csv-export-generator.php
unset( $column_headers['coupon_items'] );
return $column_headers;
}
add_filter( 'wc_customer_order_csv_export_order_headers', 'wc_csv_export_remove_column' );
// reorder columns
function wc_csv_export_reorder_columns( $column_headers ) {
// remove order total from the original set of column headers, otherwise it will be duplicated
unset( $column_headers['order_total'] );
$new_column_headers = array();
foreach ( $column_headers as $column_key => $column_name ) {
$new_column_headers[ $column_key ] = $column_name;
if ( 'order_number' == $column_key ) {
// add order total immediately after order_number
$new_column_headers['order_total'] = 'order_total';
}
}
return $new_column_headers;
}
add_filter( 'wc_customer_order_csv_export_order_headers', 'wc_csv_export_reorder_columns' );
@s011420
Copy link

s011420 commented Aug 15, 2015

where should i put these code in ?

@alexis-hexo
Copy link

Same question, where are we supposed to put this file ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment