WooCommerce - Remove downloads from menu in my account page

Cover Image for WooCommerce - Remove downloads from menu in my account page
Matheus Mello
Matheus Mello
published a few days ago. updated a few hours ago

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 called remove_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 specific downloads 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 the woocommerce_account_menu_items action with a priority of 99. This means that the code within the remove_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! 🛍️😊


More Stories

Cover Image for How can I echo a newline in a batch file?

How can I echo a newline in a batch file?

updated a few hours ago
batch-filenewlinewindows

🔥 💻 🆒 Title: "Getting a Fresh Start: How to Echo a Newline in a Batch File" Introduction: Hey there, tech enthusiasts! Have you ever found yourself in a sticky situation with your batch file output? We've got your back! In this exciting blog post, we

Matheus Mello
Matheus Mello
Cover Image for How do I run Redis on Windows?

How do I run Redis on Windows?

updated a few hours ago
rediswindows

# Running Redis on Windows: Easy Solutions for Redis Enthusiasts! 🚀 Redis is a powerful and popular in-memory data structure store that offers blazing-fast performance and versatility. However, if you're a Windows user, you might have stumbled upon the c

Matheus Mello
Matheus Mello
Cover Image for Best way to strip punctuation from a string

Best way to strip punctuation from a string

updated a few hours ago
punctuationpythonstring

# The Art of Stripping Punctuation: Simplifying Your Strings 💥✂️ Are you tired of dealing with pesky punctuation marks that cause chaos in your strings? Have no fear, for we have a solution that will strip those buggers away and leave your texts clean an

Matheus Mello
Matheus Mello
Cover Image for Purge or recreate a Ruby on Rails database

Purge or recreate a Ruby on Rails database

updated a few hours ago
rakeruby-on-railsruby-on-rails-3

# Purge or Recreate a Ruby on Rails Database: A Simple Guide 🚀 So, you have a Ruby on Rails database that's full of data, and you're now considering deleting everything and starting from scratch. Should you purge the database or recreate it? 🤔 Well, my

Matheus Mello
Matheus Mello