How to create a WooCommerce Product filter based on PHP foreach

How to create a WooCommerce Product filter based on PHP foreach