title: WooCommerce search products between price range using WP_Query
body: <p>I am currently building my own custom advanced search functionality for a WordPress website with Woocommerce. You should be able to search using filter:</p>
  
  <ul>
  <li>Category</li>
  <li>Min/Max price</li>
  </ul>
  
  <p>My current progress is attached below. This enables you to specify category slugs in the URL parameter. Returned will be posts that matches:</p>
  
  <pre><code>/**
   * Default arguments
   * @var array
   */
  
      $query = array(
          'post_status' =&gt; 'publish',
          'post_type' =&gt; 'product',
          'posts_per_page' =&gt; 10,
      );
  
  /**
   * Category search
   */
  
      if(isset($_GET['categories']) &amp;&amp; $_GET['categories']) {
          /**
           * Comma seperated --- explode
           * @var [type]
           */
  
              $categories = explode(',', $_GET['categories']);
  
          /**
           * Add "or" parameter
           */
  
              $query['tax_query']['relation'] = 'OR';
  
          /**
           * Add terms
           */
  
              foreach($categories as $category) {
                  $query['tax_query'][] = array(
                          'taxonomy' =&gt; 'product_cat',
                          'field' =&gt; 'slug',
                          'terms' =&gt; $category,
                      );
              }
      }
  /**
   * Fetch
   */
  
      $wp_query = new WP_Query($query);
  </code></pre>
  
  <p>Now, while this works great when you're searching for categories it seems it gets way more complicated when you need to search through prices.</p>
  
  <p>In raw SQL, something like below would work:</p>
  
  <pre><code>SELECT DISTINCT ID, post_parent, post_type FROM $wpdb-&gt;posts
  INNER JOIN $wpdb-&gt;postmeta ON ID = post_id
  WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish' AND meta_key = '_price' AND meta_value BETWEEN 200 AND 1000
  </code></pre>
  
  <p>I have no idea how I could implement this using WP_Query.</p>