How Conditional Attributes Work in Your WooCommerce Store

If you decide to add conditional logic to WooCommerce variations, then you should know that you can’t do it without plugins, because the core WooCommerce attribute system doesn’t support conditional/dependent attributes out of the box.

However, it can be quite useful to display a specific attribute (an attribute swatch or a standard WooCommerce select dropdown) based on the value selected in another attribute.

Right now, I will guide you step by step on how you could start using conditional attributes in your WooCommerce stores with the Conditional Attributes for WooCommerce plugin.

1. Install and activate the plugin

First of all, you need to go ahead and activate the plugin on your website. Please keep in mind that WooCommerce is required as a dependency plugin, but I assume you already have it activated.

Install and activate Conditional Attributes for WooCommerce plugin

Once we have finished with this, probably an obvious step, we can continue to the next one.

2. Configure conditions in attribute settings

It is time to visit a specific attribute settings page, the one which we want to hide or show depending on the value of another attribute.

Let’s go to Products > Attributes, then click the “Edit” link.

Create conditions for an attribute in the settings
I remember that we decided that the “Basic” value of the “Magic Level” will not have any spells, but in this screenshot I just wanted to show you what it looks like with 3 conditions at the same time.

Another question is – how to achieve “AND” and “OR” relations in conditions?

If you want a specific attribute to be displayed when at least one of the other attributes has a specific value (the “OR” relation), you can just use the “Show if” option for multiple attributes:

Display an attribute of a WooCommerce conditional variation depending on the value of two other attributes
The attribute will be displayed if the “Magic Level” attribute is “Basic” OR “Advanced” OR the “Material” attribute is “Suede”.

If you want a specific attribute to be displayed when multiple other attributes have specific values at the same time (the “AND” relation), you can just use the “Hide if” option like that:

Hide a conditional attribute depending on another attribute value
The attribute will be displayed if the “Magic Level” attribute value is anything but “Legendary” AND the “Material” attribute value is anything but “Dragonhide”.

The point is to simplify the plugin conditional logic build process, as well as the WooCommerce admin UI. Of course, it prevents us from building really complex logic, but since, by design, a WooCommerce variation can have only one value of an attribute, then we probably don’t need anything complex here.

3. Set attribute values for variations which must be conditional

Let’s say that I’m selling wizard hats on my WooCommerce store. If it doesn’t look serious to you, let me assure you – it is just an example, for the sake of simplicity.

So, I have the following attributes for my variable WooCommerce products:

  • “Magic level” – “None”, “Basic”, “Advanced”, “Legendary”.
  • “Material” – plenty of options here.
  • “Spell type” – plenty of options here as well.

Let’s say only hats with the magic level at least “Advanced” may have spells. In other words, we need to completely hide the “Spell type” attribute from our product page unless a specific “Magic level” is selected.

When creating variations, if a specific variation should not have a value of a specific attribute, it will be automatically hidden and receive an empty value of a hidden attribute:

Configure attributes for product variations
Since we decided that the “Spell” attribute is only available for “Advanced” and “Legendary” values of the “Magic level” attribute, the select dropdown of this attribute will be automatically hidden for other values.

And here you go, our result:

An example of WooCommerce conditional attributes
Of course, to make this attribute selection more interesting, you can always take a look at my other plugin, Simple Variation Swatches for WooCommerce.