'Retrieve the "Uncategorized" default WooCommerce Category ID

I am trying to get the "Uncategorized" default WooCommerce plugin category id.

I would say that since it is the first category that is created by default, the id would be 1, term_id = 1, but it is not the case.

I also tried:

$args = array(
    'taxonomy'   => 'product_cat',
    'hide_empty' => false,
    'parent'     => 0, // to get only parent terms
    'fields'     => 'id=>name',
);
$terms = get_terms( $args );

But it returns all terms. I need only the ID (term_id) of the "Uncategorized" default Category create by WooCommerce upon activation.

Is there a function like get_default_cat_id() or similar? I cannot use 'name__like' => 'Uncategorized' because the name 'Uncategorized' could be changed to something else.

Please help. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source