How To Display Woocommerce Featured Products Without Shortcode

Currently,  I’m working a custom WordPress theme that’s integrated with Woocommerce.  My first objective is to construct a custom HTML structure in displaying featured products and so my problem was creating a custom loop for it.

My solution: I just searched the PHP function from the Woocommerce plugin to where they created their query for featured products:[project/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php]

I also included on how I display the following product information (this should be inside the foreach loop or while loop:

  1. Image
  2. Product Title
  3. Product Excerpt
  4. Single Product Page Link

Image:

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
$src = $image[0];

Product Title:

$post->post_title;

Product Excerpt:

$post->post_excerpt;

Single Product Page Link:

$post->guid;

This is the snippet code for fetching featured products:

$atts = shortcode_atts( array(
 'per_page' => '2',
 'columns' => '2',
 'orderby' => 'date',
 'order' => 'asc',
 'category' => '', // Slugs
 'operator' => 'IN', // Possible values are 'IN', 'NOT IN', 'AND'.
 ), $atts, 'featured_products' );

 $meta_query = WC()->query->get_meta_query();
 $tax_query = WC()->query->get_tax_query();
 $tax_query[] = array(
 'taxonomy' => 'product_visibility',
 'field' => 'name',
 'terms' => 'featured',
 'operator' => 'IN',
 );

 $query_args = array(
 'post_type' => 'product',
 'post_status' => 'publish',
 'ignore_sticky_posts' => 1,
 'posts_per_page' => $atts['per_page'],
 'orderby' => $atts['orderby'],
 'order' => $atts['order'],
 'meta_query' => $meta_query,
 'tax_query' => $tax_query,
 );

 $featured = new WP_Query($query_args);
 $featured = $featured->posts;
 foreach( $featured as $product ){
    // display product info here
 }wp_reset_query();