How to get current category id in a template or theme functions file while using Woocommerce. In fact not only using Woocommerce but this method can be used to get the category object and subsequently the ID in normal category page.
// get the query object
$cat_obj = $wp_query->get_queried_object();
$category_name = $cat_obj->name;
$category_desc = $cat_obj->description;
$category_ID = $cat_obj->term_id;
The debugging pr() function (abbreviation of print_r()) would print the category object something similar to the following:
[term_id] => 19
[name] => Dairy Rations
[slug] => dairy
[term_group] => 0
[term_taxonomy_id] => 19
[taxonomy] => product_cat
[description] => Being a small boutique style mill we are able to custom manufacture a ration to your specific needs and requirements.
[parent] => 0
[count] => 3