admin管理员组文章数量:1336289
I offer downloadable products with woocommerce and each product is allowed to have multiple files.
I would like to display the file types/formats on the product page so users know what each product contains. Please see the image below.
One idea I have thought of is to get the names of the attached files, and then somehow print only the last four characters of each one. But I cannot figure out how to write a function that would make it work.
I offer downloadable products with woocommerce and each product is allowed to have multiple files.
I would like to display the file types/formats on the product page so users know what each product contains. Please see the image below.
One idea I have thought of is to get the names of the attached files, and then somehow print only the last four characters of each one. But I cannot figure out how to write a function that would make it work.
Share Improve this question asked Jan 2, 2016 at 13:06 Stanley UmeanozieStanley Umeanozie 1951 gold badge2 silver badges6 bronze badges2 Answers
Reset to default 3Place the following code in your meta.php
template file immediately after the lines where it prints the categories and tags. Please note, the standard practice is that you shall copy the meta.php
template file to your theme folder. So to override meta.php
, copy: woocommerce/templates/single-product/meta.php from plugin folder to yourtheme/woocommerce/templates/single-product/meta.php
<?php
global $product;
$downloads = $product->get_files();
foreach( $downloads as $key => $each_download ) {
$info = pathinfo($each_download["file"]);
$ext = $info['extension'];
$formats .= $ext . ", ";
}
echo '<p> Formats: '. $formats .'</p>';
?>
How do that too for the File Size? I have a Woo for Digital Products.. But anyone codes not worked for OutPut File Size.. But File format work good.
The code in this thread works great! But only for the file extension, I asked if there is the same code for outputting the size of the file added to the Woo product (as a virtual, downloadable)? I try use all codes from forums where is WP filesize (file size output) but not worked nothing
UPDATE
that work but needed past ID = 8677 (Manual ..) how do that, get a attached file id (Auto to per Product)?
本文标签: Display File Types For Woocommerce Downloadable Products On Product Page
版权声明:本文标题:Display File Types For Woocommerce Downloadable Products On Product Page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742406500a2468928.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论