admin管理员组文章数量:1317898
I'm trying to add the direct download link of a product to a button, but I'm stuck.
What I tried is this
<a href="<?php echo $product->downloadable_files; ?>">Download</a>
And of course it didn't work.
What is the proper code to get the product's download url?
I'm trying to add the direct download link of a product to a button, but I'm stuck.
What I tried is this
<a href="<?php echo $product->downloadable_files; ?>">Download</a>
And of course it didn't work.
What is the proper code to get the product's download url?
Share Improve this question asked Aug 27, 2015 at 9:30 Punct UlicaPunct Ulica 2171 gold badge3 silver badges8 bronze badges 1- Note that you should never output the actual downloadable file to a user, but instead grant the user permissions on a downloadable, and output that permissions link. Like this, a user can share a link to a downloadable that does not require authentication. – kontur Commented Dec 10, 2018 at 12:20
1 Answer
Reset to default 9Here is the code to get the download link for a downloadable product in WooCommerce.
$downloads = $product->get_downloads();
foreach( $downloads as $key => $each_download ) {
echo '<a href="'.$each_download["file"].'">Download</a>';
}
本文标签: post metaWhat is the code to get the download link for a product in WooCommerce
版权声明:本文标题:post meta - What is the code to get the download link for a product in WooCommerce? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742033662a2416924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论