Jul 14, 2023 | WooCommerce

How to Add or Remove Columns in the Downloads Section of a WooCommerce Store

Every online store or shopping website dealing with Digital products and using WooCommerce needs to manage the “Downloads” section of its customers in a hassle-free manner. There is a variety of columns that are displayed in the Downloads section, including Product detailsLicense KeyExpiry, and remaining Downloads. But what would you do if there is a need to remove or add more columns or modify the existing ones in that download section? Sometimes there would be a requirement to showcase some additional information about an existing downloaded product.

You would be happy to know that doing all these things on your digital store is pretty easy. In this discussion, we will introduce you to some quick tips and easy tricks to get all these things done in a very uncomplicated way.

Note that before carrying out any of these operations, it is strictly recommended to install and activate a child theme. This is due to the fact that whenever the theme is updated, all of your changes will be erased immediately.

How to Remove a Column

Let’s have a close look at the Downloads section of a WooCommerce store.

Suppose that the Downloads remaining column is unnecessary, and you want to remove it without getting into any messes.

To remove a column from the Downloads section of any WooCommerce store, you only need to access the functions.php file located in the themes folder and add the following code to its bottom.

// To remove unwanted column
function wpmz_remove_woocommerce_account_downloads_columns($columns) {
	if ( isset( $columns['download-remaining'] ) ) {
		unset( $columns['download-remaining'] );
	}
	return $columns;
}
add_filter('woocommerce_account_downloads_columns', 'wpmz_remove_woocommerce_account_downloads_columns');

After that, you have to put the Column id of the column which you want to remove into the if( ) section. Every column in the Download section has a unique Column id. To find out the Column id of a particular column you need to take the help of inspect element feature of your browser. Like in this case the Column id is “download-remaining“.

After appending the above code in the functions.php file, save it and reload the page. You will notice that the Downloads remaining column has vanished now.

After removing column

How to Add a Column and its Values

Sometimes there are requirements to add a new column in the Downloads section, and believe me, doing that is a little tricky task. If you want to extend the number of columns in the Downloads section, then just follow these simple steps to get it done in a few minutes.

In this case, we are going to add a new column to display the Order ID of all the downloaded products.

This can be easily done by adding the below code to the functions.php file. (‘Order ID’) is the column name that will be displayed on the front end, and [‘order-id’] is the Column id. You can modify these as per your requirements.

// To add a column
function wpmz_add_woocommerce_account_downloads_columns($columns) {
	$columns['order-id'] = esc_html( 'Order ID' );
	return $columns;
}
add_filter('woocommerce_account_downloads_columns', 'wpmz_add_woocommerce_account_downloads_columns');

Reload the page to see the changes. You will notice that the Order ID column has been successfully added in the Download section table.

After adding column

As of now, the new column has been placed in the download section, but it does not have any Order IDs for any of the downloads. Without any Order IDs, it is useless.

In order to display the Order IDs for all the respective downloads, we need to simply add the below code in the same functions.php file. You can easily find the [ ‘ order_id ‘ ] in the download parameter passed in the function.

// To add content in the above column
function wpmz_woocommerce_account_downloads_column_order_id($download) {
	if ( isset( $download['order_id'] ) ) {
		echo $download['order_id'];
	}
}
add_action('woocommerce_account_downloads_column_order-id', 'wpmz_woocommerce_account_downloads_column_order_id');

Immediately after adding the lines of code to the functions.php file, the Order IDs would appear in the column.

After adding values

In the same way, you can find and display several other useful information using the download parameter passed in the function. Some of them are:

  • download_url
  • product_id
  • product_name
  • download_name
  • order_key
  • access_expires

I hope that after reading this article, you’ll be able to quickly understand how to extend and reduce the number of columns in the Downloads section of a WooCommerce store. As a result, you might be able to alter the column layout of the Downloads section of your WooCommerce store to meet up your requirements.

Posted By:
Jagmohan
A curious learner who is ready to break down and simplify things to make them easily understandable to the end user. His main motive is to deliver easy-to-grab solutions in a user-friendly manner.

0 Comments

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Divi Dental Child Theme for  Dentists and Clinics

Free Divi Dental Child Theme for Dentists and Clinics

A proper Divi dental clinic child theme is necessary if you want to showcase dental treatments, practices, and services to patients on your Divi website. You need a design with appealing images of dentists and their teams providing various kinds of dental services....

5 Plugins You Can Use For a Divi Non Profit Website

5 Plugins You Can Use For a Divi Non Profit Website

If you need to build a Divi non profit website that performs according to today’s latest web designing trends, you need plugins that offer features according to those advancements.  You need plugins that are easy to use at the same time full of features and...

How to Create a Member Exclusive Blog Using Divi Conditions

How to Create a Member Exclusive Blog Using Divi Conditions

If you are a content creator, you understand the importance of providing valuable information to the audience. What will you do, if you want to share your valuable content with the registered members only? In that case, you can create a member-exclusive blog with the...

Divi WooCommerce Extended

Popular on Divi Extended

Divi Plus WooCommerce Extended Divi Layouts Extended Divi Header Layouts