This code enables you to modify the default product archive templates for any taxonomy including category & tags and any parent or child term archive in WooCommerce rather than using a custom loop.
In this case, the code removes children from specific parent product categories so only the parent products display and not products from other child categories in the hierarchy tree.
Installation
There’s only 1 step :
Copy and paste the PHP code to the end of your child themes functions file or custom functionality plugin.