title: How to get WooCommerce products from specific authors which have meta keys with specific values?
body: <p>Tying to list all bookable products from WooCommerce created by specific authors and with persons booking enabled. Say I want products with booking possible for 50 people by author_id=15;</p>
  <pre class="lang-php prettyprint-override"><code>function custom_query($q){
  
      $people = get_query_var('people');
  
      $meta_query = (array) $q-&gt;get('meta_query');
      $q-&gt;set('author__in', [15]);
  
  
      $meta_query[] = array(  
          &quot;relation&quot; =&gt; &quot;AND&quot;,
          array(
              &quot;key&quot;=&gt; &quot;_wc_booking_min_persons_group&quot;,
              &quot;value&quot;=&gt; $people,
              &quot;compare&quot; =&gt; &quot;&lt;=&quot;,
              'type' =&gt; 'BINARY'
          ),
          array(
              &quot;key&quot;=&gt; &quot;_wc_booking_max_persons_group&quot;,
              &quot;value&quot;=&gt; $people,
              &quot;compare&quot; =&gt; &quot;&gt;=&quot;,
              'type' =&gt; 'BINARY'
          )
      );
      
      $q-&gt;set('meta_query', $meta_query);
  
  }
  add_action('woocommerce_product_query', 'custom_query'); 
  </code></pre>
  <p>I get all the posts/products by author_id 15. It should only be products by author_id = 15 and within _wc_booking_min_persons_group _wc_booking_max_persons_group  range.
  Can anyone help!</p>
  <p><strong>Solution</strong></p>
  <p>Was able to solve it as below. WP_Query type casts the columns before comparison according to the <code>type</code>. The updated meta_query is given below. This works even though <code>meta_value</code> is stored as a string. Wonder why I was using Binary!</p>
  <pre class="lang-php prettyprint-override"><code>$meta_query[] = array(  
          &quot;relation&quot; =&gt; &quot;AND&quot;,
          array(
              &quot;key&quot;=&gt; &quot;_wc_booking_min_persons_group&quot;,
              &quot;value&quot;=&gt; (int) $people,
              &quot;compare&quot; =&gt; &quot;&lt;=&quot;,
              'type' =&gt; 'numeric'
          ),
          array(
              &quot;key&quot;=&gt; &quot;_wc_booking_max_persons_group&quot;,
              &quot;value&quot;=&gt; (int) $people,
              &quot;compare&quot; =&gt; &quot;&gt;=&quot;,
              'type' =&gt; 'numeric'
          )
      );
  </code></pre>