+// Force WooCommerce to believe that the downloadable file exists
+add_filter( 'woocommerce_downloadable_file_exists', '__return_true' );
+// Intercept the downloadable file as it is being returned to the customer and return something else
+function custom_override_product_file_download_path( $file_path, $object, $download_id ) {
+ // Fetch the downloadable files associated with this download
+ $files = $object->get_files();
+ // Bail out if the download ID does not match the files we requested
+ if( !isset( $files[ $download_id ] ) )
+ // The electronic download files are saved outside of WordPress’s reach
+ $downloads_directory = '/opt/bitnami/apps/wordpress/downloads/'
+ // Check if the directory we are looking for exists
+ if( !is_dir( $downloads_directory . $file_path ) )
+ // Check if the file that we are looking for exists
+ if( file_exists( $downloads_directory . $file_path . '.zip' ) ) {
+ // Set an updated file path to return to the customer
+ $file_path = $downloads_directory . $file_path . '.zip';
+ // Build a new ZIP archive in this location
+ // Set an updated file path to return to the customer
+ $file_path = $downloads_directory . $file_path . '.zip';
+add_filter( 'woocommerce_product_file_download_path', 'custom_override_product_file_download_path', 10, 3 );