WooCommerce Get Top Seller Product

Today we are going to talk about how to get top seller products in WooCommerce or wordpress. This tutorial will be helpful to place your top seller products in one place.

Below is an example:

$queryargs = array(
               'post_type' => 'product',
                'meta_key' => 'total_sales',
                'orderby' => 'meta_value_num',
            'order' => 'DESC',
                'post_status' => 'publish',
                'posts_per_page' => 10,
      );
$query = new WP_Query( $queryargs );
while ( $query->have_posts() ) {           
        $query->the_post();            
        $totalSales =   get_metadata( 'post', $query->post->ID, 'total_sales', true );
        if($totalSales){         
          if($totalSales[0] > 0) {       
              echo the_title();
          }        
      }      
}

Here is an available free WooCommerce top seller product extension.

Search

Recent Blogs

Categories

Archives

Archives

Tags