On the template for order-downloads.php there is reference to the download file delivered for the order. But the reference that it uses produces an encrypted string rather than show the actual url.
%s = $download['download_url'];
In my case the download link will be a link that needs to be bookmarked, so I need the plain url. Can I instead use something like
$download = $order -> download_file();
and if so, what to use?
For testing I tried this code…
$testip = "";
if (!empty($_SERVER['REMOTE_ADDR'])) {
$drmip = $_SERVER['REMOTE_ADDR'];
}
if $testip = "136.220.152.221" {
$testinvoice = $order->get_order_number();
$testemail = $order->get_billing_email();
$testproduct = $order->get_items();
if(strstr($testproduct,"DDD")) {
$testdownload = $order->get_downloadable_items()[0]['download_url'];
echo "<script>alert('ID = " . $testinvoice . " nEmail = " . $testemail . " nURL = " . $testdownload . "')</script>";
}
}
But I am getting an error "critical error on page"
2
Answers
If you have only one possible download by order, you can use the following (that gets the first downloadable item):
Tested and works.
The solution is perfect, but I would also like to get the URLs if there are several product downloads on the page.