title: Get WooCommerce Product total sales amount
body: <p>I have created a shortcode that will returns all products in a loop. I am looking for a way to get the total sales for each product. Right now i'm still having hard time finding the solution.</p>
  <p>This is my code:</p>
  <pre><code>    function loop_ffh_function() 
      {
          ?&gt;
  
          &lt;div class=&quot;row&quot;&gt;
      &lt;?php
      $args = array(
      'numberposts' =&gt; -1,
      'post_type' =&gt; 'product',
      'orderby' =&gt; 'date');
      $loop = new WP_Query($args);
      while ($loop-&gt;have_posts()) : $loop-&gt;the_post();
          global $product; ?&gt;         
          
          &lt;?php
          $productID = get_the_ID(); 
          
          
          ?&gt;
          &lt;div class=&quot;column&quot;&gt;
              &lt;a href=&quot;&lt;?php echo get_permalink($loop-&gt;post-&gt;ID) ?&gt;&quot;&gt;
                  &lt;?php the_post_thumbnail('full'); ?&gt;
              &lt;/a&gt;
              &lt;?php 
              $target = get_field( 'campaign_target_amount' );
              
              ?&gt;
              
              &lt;div class=&quot;progress&quot; style=&quot;margin-top:20px;&quot;&gt;
                &lt;div class=&quot;progress-bar progress-bar-warning progress-bar-striped active&quot; role=&quot;progressbar&quot;
                aria-valuenow=&quot;40&quot; aria-valuemin=&quot;0&quot; aria-valuemax=&quot;100&quot; style=&quot;width:40%&quot;&gt;
                  40%
                &lt;/div&gt;
              &lt;/div&gt;
              
              &lt;div class=&quot;row&quot;&gt;
                  &lt;div class=&quot;col-md-8&quot; style=&quot;padding-top:7px;&quot;&gt;
                      Target : &lt;b style=&quot;font-size: 18px;&quot;&gt;RM &lt;?php echo $target;?&gt;&lt;/b&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;col-md-4&quot;&gt;
                      &lt;a class=&quot;btn&quot; href=&quot;&lt;?php echo get_permalink($loop-&gt;post-&gt;ID) ?&gt;&quot;&gt;Donate Now&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;  
      &lt;?php endwhile; ?&gt;
      &lt;?php wp_reset_query(); ?&gt;
        &lt;/div&gt;
  
         &lt;?php
      }
      add_shortcode('loop_ffh', 'loop_ffh_function');
  </code></pre>
  <p>How to get a sum amount of sales for each product and display it in the loop?</p>