In WooCommerce, the “Downloads” tab of the My Account page is automatically visible to all users, even if they haven’t purchased any downloadable products. This can lead to a less-than-optimal user experience, as the tab might seem irrelevant or confusing to customers who don’t have any available downloads.
In this post, I’ll show you how to hide the “Downloads” tab for users who don’t have any downloadable products linked to their account.
With just a simple code snippet, you can make your WooCommerce store more streamlined and user-friendly by ensuring that only the customers who need to access the downloads section will see it in their account.
Whether you’re new to WooCommerce development or just looking for a way to tidy up the My Account page, this guide will walk you through everything you need. Enjoy!
PHP Snippet: Hide “Downloads” Tab If User Never Purchased a Downloadable Product @ My Account
/**
* @snippet Hide Downloads Tab @ My Account Page
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_account_menu_items', 'bbloomer_hide_downloads_tab_my_account', 9999 );
function bbloomer_hide_downloads_tab_my_account( $items ) {
$downloads = ! empty( WC()->customer ) ? WC()->customer->get_downloadable_products() : false;
$has_downloads = (bool) $downloads;
if ( ! $has_downloads ) unset( $items['downloads'] );
return $items;
}