There are a lot of people who use WooCommerce to sell their products to customers and wholesalers. For those people who are it would be nice to be able to display all orders that are made by wholesalers or customers separately.
In this post I will show you how you can easily add a new drop down to filter by user role, just next to the ‘Search for a customer’ drop down in the order overview in the admin.
Adding a piece of code
In order to create the drop down, and the functionality to filter the orders on user role, I’ve created a piece of code that can be added to your themes functions.php. Its best to add it there as it are only two functions, and not really worthy of creating a plugin if you just want to use this functionality. Of course feel free to create a separate plugin if you want to 🙂
That will do everything you will need to add a drop down to the shop order admin area of WooCommerce.
50 thoughts on “Filter WooCommerce orders by user role”
Weirdly I’m facing the same issue that Kenneth faced where the drop down menu for the filters is coming up but when a role is selected, no order data is getting displayed at all.
I’ve just tested the script and it should still work. Unfortunately I don’t have any top of the head debug tips that I can provide without knowing in-depth details about the setup / what/why this is happening.
Hey man! Just wanted to thank you for this. This is exactly what my client wanted and it works perfect.
Hello, I am trying to change the customer user role from the order page. Is it possible to change the customer’s user role from Edit order page? Please advice. Thanks in advance.
Of course its possible, just not with this code snippet in this blog, you’d need something completely different to change user role from the order page.
Your are realy awesome, thanks a lot for this piece of code !!
Have a nice day and thanks again 🙂
Amazing, thank you, life saver for a B2B shop!
This works perfectly, thank you.
Is it possible to tweak the code to show in a few additional locations via WP admin?
– WooCommerce > Analytics > Orders > Users column (next to customer name and customer type)?
– WooCommerce > Analytics > Overview > Leaderboards > Top products by user role
Or to simplify this, with your current code, what if instead of only a dropdown, the column of orders has user role added. So under screen options, you could enable “User Role” with the defaults: Order Date, Status, Total Spent, Billing , Ship to Total, Actions
This is not a simple tweak, it would require a completely new/different customization to modify the analytics reports like that..
This is A_M_A_Z_I_N_G