Documentation

Add Custom Taxonomies To Product Variations

By default, product variations will inherit the categories ( product_cat ) and tags ( product_tag ) from the parent product.

But what if you’ve added your own taxonomies to the parent product? For example, maybe you‘re using a Brands plugin and want your variations to show up when you filter by brand.

Well in v1.1.10 of Show Single Variations it became possible to add your own taxonomies to be ported over to the variations on product save.

Let’s take a look at how to add the product_brand taxonomy to the taxonomies list. In the below example, if I filter by the brand of “Nike” there’s a single result; our parent variable product. Let’s change that.

example of product brand on display

Firstly, add the following code to your child theme’s functions.php file:

/**
 * Add product_brand to taxonomies list for variations.
 * 
 * @param array $taxonomies
 *
 * @return array
 */
function iconic_add_brands_to_variations( $taxonomies ) {
	$taxonomies[] = 'product_brand';

	return $taxonomies;
}

add_filter( 'iconic_wssv_variation_taxonomies', 'iconic_add_brands_to_variations', 10, 1 );

We’re filtering the $taxonomies array for variations and adding product_brand to the list.

With this snippet enabled, when you re-save the parent product, any brands associated with the product will also be saved to the variations.

shop example with multiple products with brands

Are you using WooCommerce Show Single Variations yet?

Start your 14-day free trial right now and get instant access to the features described in this article.

or learn more

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.

WooCommerce Show Single Variations

WooCommerce Show Single Variations

Not got the plugin yet? Get instant access right now, free for 14 days.

or learn more

Still need help?

If you haven't found what you're looking for in our documentation, please contact support.

Get Support