Website Building » WooCommerce » What Are Product Categories WooCommerce?

What Are Product Categories WooCommerce?

Last updated on January 23, 2023 @ 11:11 am

Product categories are a way of grouping products in WooCommerce. By default, WooCommerce will create a top-level category for each product type that you have registered. For example, if you have products that are both physical and digital, WooCommerce will create a product category called ‘Products’ and another called ‘Downloads’.

You can override the default behavior by specifying your own product categories when you register a product type. For example, if you have a digital product that you want to categorize as an ‘ eBook’, you can do so by using the following code:

add_filter( 'woocommerce_register_taxonomy_product_cat', 
'my_custom_product_categories' );
function my_custom_product_categories( $taxonomy ) 
{$taxonomy->add( 'ebooks', array('label' => __( 'eBooks', 'woocommerce' ),) );}

You can also use this code to add subcategories. For example, if you want to add a subcategory for ‘Fiction’ eBooks, you can use the following code:

PRO TIP: Product categories in WooCommerce can be incredibly helpful for organizing your products and making it easier for customers to find what they’re looking for – but they can also be a little confusing to set up. This guide will help you get started with product categories in WooCommerce.
add_filter( 'woocommerce_register_taxonomy_product_cat',
'my_custom_product_categories' );
function my_custom_product_categories( $taxonomy ) 
{ // Add parent category. $taxonomy->add( 'ebooks', array('label' => __( 'eBooks', 'woocommerce' ),) );
// Add child category.
$taxonomy->add( 'ebooks-fiction', array('label' => __( 'Fiction', 'woocommerce' ),'parent' => 'ebooks',
// Parent must exist before child is added.) );}
Kathy McFarland

Kathy McFarland

Devops woman in trade, tech explorer and problem navigator.