wordpress - How to use a WooCommerce shortcode as PHP code
one text
Solution:
Inside any PHP code, use dedicated WordPress function as follow:
echo do_shortcode("[products columns='3' attribute='ir' terms='20' orderby='date']");
or inserting that on the html code from a php file:
<?php echo do_shortcode("[products columns='3' attribute='ir' terms='20' orderby='date']"); ?>
It will work on your php code.
Source