title: WooCommerce get sale price
body: <p>I want to be able to show the current price and sale price if it exists within my WP_Query products loop. At the moment my code just replaces the current price with the sale price. I want an if statement that checks if the sale price is there or not. If it is I want to display both;</p>
  
  <p>Here's my code; </p>
  
  <pre><code>&lt;?php   
      $args = array(
          'post_type' =&gt; 'product',
          'meta_key' =&gt; 'total_sales',
          'orderby' =&gt; 'meta_value_num',
          'posts_per_page' =&gt; 4,
      );
      $query = new WP_Query( $args );
  ?&gt;
  
  &lt;?php if($query-&gt;have_posts()): ?&gt;
      &lt;div class="container" id="best_sellers"&gt;
          &lt;div class="row"&gt;
          &lt;?php while( $query-&gt;have_posts() ): $query-&gt;the_post(); ?&gt;
              &lt;?php $product = wc_get_product(get_the_ID());?&gt;
  
              &lt;div class="col-md-3"&gt;
                  &lt;div class="cont"&gt;
                      &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                          &lt;div class="image_cont"&gt;
                              &lt;?php the_post_thumbnail(); ?&gt; 
                          &lt;/div&gt;
  
                          &lt;p class="sku"&gt;&lt;?php echo $product-&gt;get_sku(); ?&gt;&lt;/p&gt;
  
                          &lt;p class="title"&gt;&lt;?php the_title(); ?&gt;&lt;/p&gt;
                      &lt;/a&gt;
  
                      &lt;div class="quantity"&gt;
                          &lt;p&gt;Quantity: &lt;/p&gt;
                          &lt;button class="increment"&gt;+&lt;/button&gt;
                          &lt;input type="text" value="1" min="1" max="&lt;?php echo $product-&gt;get_stock_quantity(); ?&gt;"&gt;
                          &lt;button class="decrement"&gt;-&lt;/button&gt;
                      &lt;/div&gt;
  
                      &lt;p class="price"&gt;&lt;?php echo wc_price( wc_get_price_including_tax( $product ) ); ?&gt;&lt;/p&gt;
  
                      &lt;a href="&lt;?php echo $product-&gt;add_to_cart_url();?&gt;" data-quantity="1" class="basket_btn button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="&lt;?php the_id(); ?&gt;" data-product_sku="&lt;?php echo $product-&gt;get_sku(); ?&gt;" aria-label="Add “&lt;?php the_title(); ?&gt;” to your cart" rel="nofollow"&gt;Add to Basket&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;?php endwhile; ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>If you look at the price class you can see my code for getting the price.</p>
  
  <p>update: I have been looking through the WooCommerce templates files and found this;</p>
  
  <pre><code>&lt;?php if ( $product-&gt;is_on_sale() ) : ?&gt;
  </code></pre>
  
  <p>This works, I just need to be able to grab both prices separately as at the moment</p>
  
  <pre><code>&lt;?php echo wc_price( wc_get_price_including_tax( $product ) ); ?&gt;
  </code></pre>
  
  <p>just gets overwritten by the sale price  </p>