WooCommerce: Add a free download for all your customers in their account

Do you want to have a detail with the customers of your online store? Or maybe you want them to always have your catalog at hand in their account?

A touch of customization for your Ecommerce can be to offer your customers a free download that is always available on their user account page, by default.

This trick is very easy to apply, just create a code like the following…

/* Download by default in all accounts */
add_filter( 'woocommerce_customer_get_downloadable_products', 'wphelp_free_download', 9999, 1 );
 
function wphelp_free_download( $downloads ) {
   $downloads[] = array(
      'product_name' => 'Download description',
      'download_name' => 'Button tag',
      'download_url' => 'https://mywoostore.com/wp-content/uploads/name-of-file.pdf',
   );
   return $downloads;
}Code language: PHP (php)

Of course, you have to customize it, in particular the following lines:

'product_name' => 'Download description', 
'download_name' => 'Button tag', 
'download_url' => '/wp-content/uploads/name-of-file.pdf',Code language: PHP (php)

It could be something like that, for example:

/* Download by default in all accounts */
add_filter( 'woocommerce_customer_get_downloadable_products', 'wphelp_free_download', 9999, 1 );
 
function wphelp_free_download( $downloads ) {
   $downloads[] = array(
      'product_name' => 'catalogue 2020/21',
      'download_name' => 'Download',
      'download_url' => 'https://mywoostore.com/wp-content/uploads/2020/04/catalogue.pdf',
   );
   return $downloads;
}Code language: PHP (php)

Once you have customized it you can add the code at the end of the functions.php file (before ?> if there is) of the active theme or to your customizations plugin if you have it.

When you save the changes, the next time your customers go through the download section of their account they will see this change.

And they will always have available your catalog, manual, digital gift, whatever you want.

Read this post in Spanish: WooCommerce: Añade una descarga gratuita para todos tus clientes en su cuenta

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Skip to content