Forked from woogist/woocommerce-customer-order-csv-export-renaming-removing-reordering-columns.php
Created
October 9, 2014 16:07
-
-
Save tamarazuk/68aa8cfde324091b0054 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// 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' ); |
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
where should i put these code in ?