Last active
September 27, 2015 15:02
-
-
Save woogist/8835906 to your computer and use it in GitHub Desktop.
WooCommerce Customer/Order CSV Export: Change export filename
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 | |
// 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of
$replacement = array( date( 'Y-m-d' ) );
Can we have something like
$replacement = array( order_number );
How can I make this work?