Recently I needed to pass the current taxonomy ID for a category and sub category in WordPress. I came up with a variety of ways it worked and did not work. Here are some details that should be helpful when you want to know the ID of the category the user is currently on.
How to Get WordPress Current Category ID and even sub category ID
Option 1: Get Category ID (Does Not Work with Subcategory)
#$categories = get_the_category();
#$category_id = $categories->cat_ID;
This will return the Category ID but it did not display the current ID if I was on a subcategory.
Option 2: Get Category ID & Subcategory ID
$category = get_queried_object();
$categorynew = $category->term_id;
Thanks to pagecrafter.com I used this because it allowed me to retrieve the category ID for categories and subcategories.