woocommerce_file_download_filename
Filter the filename of a downloadable product file before it is served.
Usage
add_filter( 'woocommerce_file_download_filename', 'wp_kama_woocommerce_file_download_filename_filter', 10, 2 );
/**
* Function for `woocommerce_file_download_filename` filter-hook.
*
* @param string $filename Filename derived from the file URL.
* @param integer $product_id Product ID of the product being downloaded.
*
* @return string
*/
function wp_kama_woocommerce_file_download_filename_filter( $filename, $product_id ){
// filter...
return $filename;
}
- $filename(string)
- Filename derived from the file URL.
- $product_id(int)
- Product ID of the product being downloaded.
Changelog
| Since 2.2.0 | Introduced. |
Where the hook is called
woocommerce_file_download_filename
woocommerce/includes/class-wc-download-handler.php 241
$filename = apply_filters( 'woocommerce_file_download_filename', self::derive_filename_from_file_path( $file_path ), $product_id );
woocommerce/src/Admin/API/Reports/Downloads/Controller.php 70
$response->data['file_name'] = apply_filters( 'woocommerce_file_download_filename', $filename, $product_id );