Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save woogist/8835906 to your computer and use it in GitHub Desktop.
Save woogist/8835906 to your computer and use it in GitHub Desktop.
WooCommerce Customer/Order CSV Export: Change export filename
<?php
// change the date format for the filename from YYYY_MM_DD_HH_SS to YYYY-MM-DD
function wc_csv_export_edit_filename( $post_replace_filename, $pre_replace_filename ) {
// define your variables here - they can be entered in the WooCommerce > CSV Export > Settings tab
$variables = array( '%%timestamp%%' );
// define the replacement for each of the variables in the same order
$replacement = array( date( 'Y-m-d' ) );
// return the filename with the variables replaced
return str_replace( $variables, $replacement, $pre_replace_filename );
}
add_filter( 'wc_customer_order_csv_export_filename', 'wc_csv_export_edit_filename', 10, 2 );
Copy link

ghost commented Feb 25, 2014

Instead of
$replacement = array( date( 'Y-m-d' ) );
Can we have something like
$replacement = array( order_number );

How can I make this work?

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