Hi Robert,
Adding Order ID to CSV File is very easy. You can add following piece of code to your theme’s functions.php file.
function wpg_add_columns($cols) {
$cols['wc_settings_tab_order_id'] = __('Order ID', 'mytheme');
return $cols;
}
add_filter('wpg_order_columns', 'wpg_add_columns');
function wpg_add_fields($settings) {
$settings['payment_method'] = array(
'name' => __( 'Order ID', 'woocommerce-simply-order-export' ),
'type' => 'checkbox',
'desc' => __( 'Order ID', 'woocommerce-simply-order-export' ),
'id' => 'wc_settings_tab_order_id'
);
return $settings;
}
add_filter('wc_settings_tab_order_export', 'wpg_add_fields');
function csv_write( &$csv, $od, $fields ) {
if( !empty( $fields['wc_settings_tab_order_id'] ) && $fields['wc_settings_tab_order_id'] === true ){
array_push( $csv, $od->id );
}
}
add_action('wpg_before_csv_write', 'csv_write', 10, 3);
Please let me know if this works for you.
Thanks for that. Now I have another one. The order date and the invoice date. I have searched the database but I can’t find it.
I think the order date is equal to the post date so I tried to add $post->post_date to the array (order_export_procecess.php) inside the loop but I’m not getting any output.
Any other ideas?
Hello Robincreations,
Please refer this thread for adding more fields:
https://wordpress.org/support/topic/adding-fields-4?replies=5
As far as adding date, please refer this function. http://codex.wordpress.org/Function_Reference/get_the_date
Let me know if this helps you.
Regards