The WooCommerce My Account > Downloads endpoint features a table which lists the available downloads. This table has 4 default columns: Product, Downloads remaining, Expires, Download (as you can see from the screenshot below).
Now, it’s very likely you may want to rename these headings into something more readable or understandable. On top of that, you may want to change the content of whatever column – you’ll find a workaround for this as well. Enjoy!
Continue reading WooCommerce: Rename Downloads Table Column Title @ My Account
In WordPress, you get the “Sorry, This File Type Is Not Permitted for Security Reasons” error when you try to upload certain files to the Media library. Similarly, in WooCommerce you may get the same error when you try to upload a downloadable product download files.
Why is that? Well, by default WordPress only allows certain file extensions to be uploaded to the site. For example PNG, JPG, PDF, PPT, DOC, MP3 and MP4 are within the allowed file types – the reason being they are “safe” and won’t contain malicious code that could create problems within a WordPress install.
The thing is – I’ve started selling my first downloadable product (a mini-plugin) here on Business Bloomer and I needed to upload a ZIP file (the mini-plugin), a JSON file (a Code Snippet export file for those who don’t like plugins) and a TXT file (the plugin’s raw code for those who like to play with PHP). All went smoothly for the ZIP upload, but as soon as I tried uploading the JSON and TXT files I got the “Sorry, This File Type Is Not Permitted for Security Reasons” error.
Panic? Not really. It’s only a matter of finding the right code to change this default WordPress behavior. So, say hello to the “upload_mimes” filter, which allows us to do just that. Enjoy!
Continue reading WooCommerce: Fix “Sorry, This File Type Is Not Permitted for Security Reasons” For Downloadable Products
If you sell no downloadable products, the Downloads section of the WooCommerce My Account page will always be empty (in this case, you should completely hide the My Account Download tab). Besides, if you do sell downloadable products but customers never purchased such items, the same will happen.
So, what if you wanted to grant at least a default download file to all your customers? Well, the “woocommerce_customer_get_downloadable_products” WooCommerce filter allows us to add files to the list (empty or non empty) of customer downloadable files. Here’s how it’s done!
Continue reading WooCommerce: Add a Custom Download File @ My Account
When you’re doing custom PHP work, this snippet will come handy. It’s a quick way to get a sublist of product IDs based on product meta criteria – in this case we’ll get a list of products that have “_downloadable” set to “yes” (which, translated in English, means they are “downloadable”).
Of course, you can edit this snippet to get any sublist of product IDs, for example in stock products, custom field value products, below/above sales number, and so on. Whatever is stored as a custom field can be used. Enjoy!
Continue reading WooCommerce: Get List of Downloadable Products