title: How to get order detail by product id in woocommerce
body: <p>How to get all order detail by product id in woo-commerce my code is blow but i can't get detail.</p>
  
  <pre><code>function getProductId($id){
  $customer_orders = get_posts( array(
      'numberposts' =&gt; -1,
      'meta_key'    =&gt; '_customer_user',
      'meta_value'  =&gt; get_current_user_id(),
      'post_type'   =&gt; wc_get_order_types(),
      'post_status' =&gt; array_keys( wc_get_order_statuses() ),
  ) );
  
  foreach ($customer_orders as $customer) {
  
      $order = wc_get_order( $customer-&gt;ID );
      $items = $order-&gt;get_items();
  
      foreach ( $items as $item ) {
          if ($id == $item-&gt;get_product_id())
              return true;
      }
  } } global $product; $id = $product-&gt;get_id(); getProductId($id);
  </code></pre>