WooCommerce - Remove downloads from menu in my account page
How to Remove Downloads from Menu in WooCommerce My Account Page 😎💻
If you're using WooCommerce and want to get rid of the Downloads menu from your My Account page, you're in the right place! This blog post will walk you through the process of removing the Downloads feature with easy-to-follow steps. Let's dive in! 🏊♂️
The Problem 🤔
The My Account page in WooCommerce provides customers with access to various options, including Downloads. However, not every online store needs this feature. If you want to simplify the user experience by removing the Downloads menu option, you're not alone!
The Solution 👍
To remove the Downloads menu from the WooCommerce My Account page, you can use a hook called woocommerce_account_menu_items
. A hook allows you to modify or remove elements in WordPress or WooCommerce without changing the core files.
Here's a simple code snippet that will do the trick:
function remove_wc_downloads_menu( $items ) {
unset( $items['downloads'] );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'remove_wc_downloads_menu', 99 );
This code creates a function called remove_wc_downloads_menu
that specifically targets the Downloads menu item and removes it from the list of menu items. The add_filter
function is then used to apply this modification to the woocommerce_account_menu_items
hook.
You can add this code snippet to your theme's functions.php
file, within a child theme, or even in a custom plugin.
Example and Explanation 🚀📚
Let's break down the code snippet and explain what each part does.
function remove_wc_downloads_menu( $items ) {
unset( $items['downloads'] );
return $items;
}
The
function remove_wc_downloads_menu( $items )
creates a function calledremove_wc_downloads_menu
that takes an array of menu items as a parameter. In this case, the WooCommerce menu items associated with the My Account page.The
unset( $items['downloads'] )
line removes the specificdownloads
menu item from the array.Finally,
return $items
returns the modified menu items array after removing the Downloads menu option.
add_filter( 'woocommerce_account_menu_items', 'remove_wc_downloads_menu', 99 );
The
add_filter( 'woocommerce_account_menu_items', 'remove_wc_downloads_menu', 99 )
line hooks into thewoocommerce_account_menu_items
action with a priority of99
. This means that the code within theremove_wc_downloads_menu
function will execute when the My Account menu items are being generated but before they are displayed.
Conclusion 🎉💬
By using the woocommerce_account_menu_items
hook and a simple code snippet, you can effortlessly remove the Downloads menu from your WooCommerce My Account page. This allows you to create a cleaner and more focused user experience for your customers.
If you found this guide helpful, or if you have any other WooCommerce-related questions, let us know in the comments below! We'd love to hear from you and help you out. Happy customizing! 🛍️😊