maxwilliam
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Download ProblemI found a temporary solution.
In the file: includes/class-wc-download-handler.php
At line 195 : $filename = current (explode (‘?’, $filename));That’s what’s causing the problem because with Google Drive the name of the file is not transmitted in the url. So I try to recover this file name using curl but I didn’t succeed…
So, when you create your product and add a file to download, you must fill the name of your file and your url. So I use the name field to name my file (same name as my file stored in my Google Drive with extension).
Then, I made changes at line 194 :
if ( strstr( $filename, ‘?’ ) ) {
$filename = current( explode( ‘?’, $filename ) );
}In :
if ( strstr( $filename, ‘?’ ) ) {
$filename = current( explode( ‘?’, $filename ) );$product = wc_get_product( $product_id );
$drive_filename = $product->get_downloads();
foreach( $drive_filename as $key => $each_download ) {
$filename = $each_download[“name”];
}
}It works for the moment 🙂
Forum: Plugins
In reply to: [WooCommerce] Download ProblemI think I found something. In the file : includes/class-wc-download-handler.php
I changed line 433 :
header( ‘Content-Disposition: attachment; filename=”‘ . $filename . ‘”;’ );
In : header( ‘Content-Disposition: attachment; filename=”blablabla.doc”;’ );Now this changes the name of the file when i try to download. So there is a problem getting the file name from the url…