Last updated - February 26, 2020
Most of the time, you would never need to create private categories in WooCommerce. The purpose of your WooCommerce store is to sell your products to as many users as possible, not to exclude your customers from certain categories. However, there are occasions when you do want to make some or all your WooCommerce categories private. In this post, I’ll look at why and how to achieve this.
What do we mean by a private category?
When we refer to a private category, we could also use the terms ‘protected’, ‘restricted’, or even ‘members only’. All these terms, when applied to categories, can be used to mean the same thing – namely that the categories and the products within them are not available to everyone. So a private category in WooCommerce can only be accessed by certain customers.
Creating private categories in WooCommerce
In this article, I’m going to walk through a very simple method for creating private categories in WooCommerce. You’ll be able to choose which categories are private, which users can access them, and what to do with users who are prevented from accessing them. We’ll use a simple plugin called WooCommerce Members Only by Plugin Republic which you can use to make your categories private with a minimum of effort.
Why create private categories in WooCommerce?
In many ways, it seems counter-intuitive to want to make categories private. After all, the primary purpose of your online store is to sell as many products as it possibly can. Preventing customers from being able to access your products would seem to obstruct this purpose.
However, there are several good reasons for creating private categories, some of which might even lead to more sales in the long run. Common reasons include:
- Staff only: let’s say your online store is only part of your overall business. Although you sell your products online, you might also want to use your WooCommerce store to supply your staff with certain products. These might be perks for your staff, specialist equipment, or even products at a special staff-only discount. Whatever the reason, it makes sense to assign all these products to a ‘Staff Only’ category and make this private so that your customers can’t access it.
- Members only: if you are running a membership style site, it’s pretty common practice to restrict some content to your members. After all, there has to be some advantage to becoming a member of your site – getting access to members only products is a key one.
- Wholesale / retail: one approach to creating differential pricing for your wholesale and retail customers is to create separate categories for wholesale products. You can then make these categories private in order to protect them from your retail customers.
- Age restricted sites: if you require your customers to verify their identity in any way (e.g. by confirming their age) before they can purchase your products, then creating private categories is the perfect way to prevent any non-verified users from making unauthorised purchases.
How to create private categories in WooCommerce
So, having established that private WooCommerce categories are not as counter-intuitive as we might have thought, let’s look at how to create them. As I mentioned, I’m using the WooCommerce Members Only plugin.
WooCommerce Members Only plugin
Although simple to set up, the WooCommerce Members Only plugin will allow you to do some powerful stuff with your store. Once installed and activated, go to WooCommerce > Settings > Members Only to configure your settings.
One of the great things about this plugin is that it only has a few settings so you can configure it within a few minutes.
How to define which customers can access private categories?
There are several different approaches for deciding which customers can access private categories and which customers are restricted. Use the Restriction Method setting to choose between ‘Log In Status’, which means that only logged-in users would be able to access private categories; ‘Password’, which means that users will need a password to access content; and ‘User Role’, which means you can specify which user roles will be permitted to view the private categories.
How to define which categories are private?
This is easily done. Under ‘Restricted Content’, select ‘Specified Categories’ then in the ‘Restricted Categories’ field enter the categories that you’d like to make private.
That’s it – within about two minutes you’ve created private categories in your WooCommerce store.
However, there might be some fine-tuning that you’d like to do.
How to hide protected products in archive pages?
One of the choices you’ll need to make about your private categories is how private you want them to be. I think your options are:
- Completely invisible to users who don’t have access
- Visible but not accessible
If you select the ‘Hide Products in Archive’ option then you’ll make private categories completely invisible, meaning that all reference to them will be removed for users who are restricted. So the shop page, all archive pages, and product pages will not be visible. This is important if your private products should not be discoverable by every user to the site, for instance if you have a private category for staff-only products then you probably wouldn’t want this to be visible to your normal paying customers.
However, if you are using private categories as a kind of incentive, e.g. to show non-members the kind of products that are available to members, then you might want to use private categories as a kind of teaser. Keep the ‘Hide Products in Archive’ option unselected and private categories will still appear in the shop and archive pages but the products will not be purchasable unless the customer is permitted.
How to remove a private category from site menus?
If you’ve chosen to make your private categories totally invisible from any unauthorized users then it makes sense to hide any reference to those categories from your site menus. To do this, just enter the names of the menu item in the ‘Exclude from Menu’ field. These menu items will be hidden from any users who don’t have permission to view the private categories.
How to choose which widgets to display to restricted users?
Furthermore, you might have widgets on your site that refer to private categories. Using the ‘Widget Whitelist’ setting, you can decide which can still be displayed to users who are prevented from viewing the private categories. A typical example of this would be the search widget which you would want to make available to all users.
To make use of this feature, just enter the names of widgets that should be available to all in the ‘Widget Whitelist’ field. You can find the names of widgets by going to Appearance > Widgets. The names are displayed under each sidebar.
How will you use WooCommerce Members Only?
As I said at the start, private categories is a slightly niche requirement in WooCommerce – but there are very definitely scenarios when it’s essential. If you need any help with the plugin, just let me know directly at Plugin Republic or leave a comment below.