title: WooCommerce Subscriptions - Get related orders Ids for a specific subscription
body: <h2>Is there woocommerce function that will return me all related orders (at least the order ID) for the specific subscription that user has bough?</h2>
  
  <p>I have found in this official documentation <a href="https://docs.woocommerce.com/document/subscriptions/develop/functions/" rel="noreferrer">Subscription Function &amp; Property Reference</a>: </p>
  
  <pre><code>WC_Subscription::get_related_orders( $return_fields, $order_type );
  </code></pre>
  
  <p>But this does not seem to be for specific subscription?</p>
  
  <p>When ever I try to run it I get a <strong>fatal error</strong> no mater what I pass in:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Using $this when not in object context in
    C:\xampp\htdocs\mysite.com\wp-content\plugins\woocommerce-subscriptions\includes\class-wc-subscription.php:1413</p>
  </blockquote>
  
  <p>I am making my own plugin and I select all subscriptions where <code>post status = wc-active</code> from post table. I have looked in the "<code>woocommerce_order_items</code>", "<code>woocommerce_order_itemmeta</code>" and "<code>postmeta</code>" tables but neither of them provide way to get related orders for user bought subscription...</p>
  
  <p>If I only knew where are the relation for user bought subscriptions and its related orders, then i could write some sql but I have no idea and google does not yield any results either.</p>
  
  <p>Any ideas?</p>
  
  <p>My setup:</p>
  
  <ul>
  <li>php version 7.0.4 </li>
  <li>wordpress version 4.7.3 </li>
  <li>woocommerce 2.6.8</li>
  <li>woocommerce subscriptions: 2.0.18</li>
  </ul>