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.

remove column in WooCommerce downloads

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“.

remove column in WooCommerce downloads using id

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.

column in WooCommerce downloads removed

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.

Add column in WooCommerce downloads

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.

Display order IDs in WooCommerce downloads

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

These configuration will be quite helpful in further customizations after you had built your WooCommerce store with Divi.

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.

Why Switch to WordPress from Other CMS

Why Switch to WordPress from Other CMS

Are you still using a CMS other than WordPress? If so, you might be missing the most robust and interesting features that only WordPress offers. So, you need to change your CMS as soon as possible. WordPress has surprisingly earned the most commonly used CMS status...

How to Add Citations and Bibliography in WordPress Posts

How to Add Citations and Bibliography in WordPress Posts

If you want to know how to add citations and bibliography in WordPress posts, you are on the right track. Citations play a huge role in helping companies and brands in search engine optimization.  Through the citations, search engines understand a business’...

Divi WooCommerce Extended