I have a quick question in regards to WooCommerce and downloadable files. I would like to make the purchased products play in My Account section rather than easily download them (the exact opposite of how WooCommerce handles downloadable/virtual products).
I have managed to locate the code that handles the view of the "Downloadable products" in My Account section (templates/order/order-downloads.php), however I can't make it work, since the link results in the "safe version"
https://example.com/?download_file=XXXX&order=wc_order_cSzbzLqustvlw&email=XXXXXXXX&key=XXXXX
Instead of the friendly/unsecured file URL
I have changed this line to make it work as audio shortcode, however it doesn't play since it doesn't get the full file URL.
case 'download-file':
echo do_shortcode('[audio src="' . esc_url( $download['download_url'] ) . '"]');
break;
I know it's not the best approach to change the code there, however I just want to make it work in a way that the customer can play the file, but can't download it directly. Can you help me how to achieve this?
EDIT
With the help of Martin Mirchev I was able to get the following:
case 'download-file':
$url_file = esc_url( $download['file']['file'] );
$address = explode(".", $url_file);
if ($address[2] == "mp3") {
echo "<div id='content' class='fancybox-hide' style='min-width:450px; min-height:250px;'>";
echo do_shortcode('[audio src="' . esc_url( $download['file']['file'] ) . '"]');
echo "</div>";
echo "<a href='#content' class='ari-fancybox'>Listen to MP3</a>";
}
Would there be a possibility to apply the same customization in WooCommerce as opposed to overwriting the template file?