title: WC_Product_Query return empty in functions.php but working in archive-product.php
body: <p>Am using WooCommerce 3.6.5.</p>
  
  <p>I need all variable products in my functions.php file so for this I want to use WC_Product_Query in my functions.php file but it always return the empty data. But the same code working in WooCommerce template files (archive-product.php) and return correct data.</p>
  
  <p>here is my code</p>
  
  <pre><code>$query = new WC_Product_Query(array(
              'limit'=&gt;-1,
              'type' =&gt; 'variable',
              'return' =&gt; 'ids'
          ));
          $variableproducts = $query-&gt;get_products();
          echo '&lt;pre&gt;';
  echo 'print from functions.php';
  print_r($variableproducts);
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p>can anyone help me why <code>WC_Product_Query</code> class not return correct data in functions.php or is there any another way to get all variable products ids in functions.php file?</p>