How to create Woocoomerce order query with product name?
Hi i need to get all orders that belongs to or contain A PRODUCT. ie if product1 is my product name then i need to get all orders in the loop that contain this product .
For to get order detail i use the following query
$args = array(
'post_type' => 'shop_order',
'post_status' => 'publish'
$order = new WC_Order($order_id);
..details i fetched from query ..
to get item details i can use $order->get_items();
I want to
(1) it is the best method to fetch order details in the loop ?
(2)How to fetch orders that belongs to product1 [where product1 is my product name ] .?