If I am on a product archive page then how can I get current product category ID in product archive page. I am using this but no result:
global $wp_query;
$category_name = $wp_query->query_vars['product_cat'];
$category_object = get_term_by('name', $category_name, 'product_cat');
$category_id = $category_object->term_id;
2 s
I solve This To get the current category ID.
$cate = get_queried_object();
$cateID = $cate->term_id;
echo $cateID;
and it works like a charm.