I’m trying to change the product download url to the custom url that was input by admin. I’ve done this on a single product page using the code below. But it is not working in the Downloads page. I tried updating the code in order_download.php file but it’s not responding.
// Declaring $product variable from woocommerce, this isn't needed if previously declared
global $product;
// get all downloadable files from the product
$files = $product->get_files();
echo "<style>.elementor-widget-jet-single-add-to-cart > div > div > form{display:none;}</style>";
//Loop through each downloadable file
foreach( $files as $file ) {
$new_url = $file['file'];
//store the html with link and name in $output variable assuming the $output variable is declared above
$links_html .= "<a class='{$classes}' href='{$new_url}' data-key='{$key}' target='_blank' data-product-id='{$id}'>{$name}</a>";
}
2
Answers
Resolved now, all I did was change $file['file'] to $file["file"]['file']
Initialize the $links_html at the top.