I used the following code to get the list of product categories form WooCommerce in my WordPress website:
Do not use WP_Query() or get_posts(). From the WooCommerce doc:
wc_get_products and WC_Product_Query provide a standard way of retrieving products that is safe to use and will not break due to database changes in future WooCommerce versions. Building custom WP_Queries or database queries is likely to break your code in future versions of WooCommerce as data moves towards custom tables for better performance.
You can retrieve the products you want like this:
$args = array(
'category' => array( 'hoodies' ),
'orderby' => 'name',
);
$products = wc_get_products( $args );
WooCommerce documentation
Note: the category argument takes an array of slugs, not IDs.