Display woocommerce categories and product listing

WordPress: 5.2

Woocommerce: 3.6

If you want to group products subcategory wise the default woo-commerce product listing should be overridden.

The product listing uses the archive-products.php file in plugin/woocommerce/templates. Now you have to override archive-products.php file to your theme/woocommerce folder. If the woocommerce folder is not present create a folder named woocommerce and place your PHP file there. Here you can edit the file.The code between woocommerce_product_loop_start(); and woocommerce_product_loop_end(); lines can be deleted and your custom code for grouping products can be placed there. 

If incase archive-product.php file cannot be overridden you should add this line of code to functions.php in your theme.


function mytheme_add_woocommerce_support(){
add_theme_support('woocommerce');
}
add_action( 'after_setup_theme','mytheme_add_woocommerce_support');