0

I have one problem that I'm trying to deal with. I have below array of get_children for Woocommerce order and its suborders created by Dokan plugin, and I'm trying to integrate it with another plugin.
What I need is to get suborder (child post ID) that belongs to specific seller (post_author). So what I have is:

  • Parent post ID - $reservation->transaction_id - Order ID
  • post_author - $seller_id - returns seller ID

    $sub_orders = get_children( array(    
    'post_parent' => $reservation->transaction_id,    
    'post_type'   => 'shop_order',    
    'post_status' => array( 
    'wc-pending', 'wc-completed', 'wc-processing', 'wc-on-hold' 
    )
    ) );
    

The array returns:

array ( 
1810 => WP_Post::__set_state(array( 
'ID' => 1810, 
'post_author' =>'post_author' =>, 
'post_date' => '2016-10-16 22:13:35', 
'post_date_gmt' => '2016-10-16 22:13:35', 
'post_content' => '', 
'post_title' => 'Order – October 16, 2016 @ 10:13 PM', 
'post_excerpt' => '', 
'post_status' => 'wc-processing', 
'comment_status' => 'open', 
'ping_status' => 'closed', 
'post_password' => 'order_5803fb8de7789', 
'post_name' => 'order-oct-16-2016-1013-pm-3', 
'to_ping' => '', 
'pinged' => '', 
'post_modified' => '2016-10-16 22:13:35', 
'post_modified_gmt' => '2016-10-16 22:13:35', 
'post_content_filtered' => '', 
'post_parent' => 1808, 
'guid' => 'https://example.com/?post_type=shop_order&p=1810', 
'menu_order' => 0, 'post_type' => 'shop_order', 
'post_mime_type' => '', 
'comment_count' => '1', 
'filter' => 'raw', )), 
1809 => WP_Post::__set_state(array(
 'ID' => 1809, 
 'post_author' => '2', 
 'post_date' => '2016-10-16 22:13:34', 
 'post_date_gmt' => '2016-10-16 22:13:34', 
 'post_content' => '', 
 'post_title' => 'Order – October 16, 2016 @ 10:13 PM', 
 'post_excerpt' => '', 
 'post_status' => 'wc-completed', 
 'comment_status' => 'open', 
 'ping_status' => 'closed', 
 'post_password' => 'order_5803fb8dd09ed', 
 'post_name' => 'order-oct-16-2016-1013-pm-2', 
 'to_ping' => '', 'pinged' => '', 
 'post_modified' => '2016-10-16 23:48:58', 
 'post_modified_gmt' => '2016-10-16 23:48:58', 
 'post_content_filtered' => '', 
 'post_parent' => 1808, 
 'guid' => 'https://example.com/?post_type=shop_order&p=1809', 
 'menu_order' => 0, 
 'post_type' => 'shop_order', 
 'post_mime_type' => '', 
 'comment_count' => '2', 
 'filter' => 'raw', )), )
  • The title of the question is confusing after reading the question's text Can you please clarify it more? Thanks – birgire Oct 18 '16 at 13:43
0

If you want to query by a post author , you can try the author input argument:

$sub_orders = get_children( 
    array(    
        'author'      => $seller_id,
        'post_parent' => $reservation->transaction_id,    
        'post_type'   => 'shop_order',    
        'post_status' => array( 
            'wc-pending', 
            'wc-completed', 
            'wc-processing', 
            'wc-on-hold' 
        )
    ) 
);

Note that get_children() calls get_posts(), that is again a wrapper for WP_Query, so you can use the author_name, author__in and author__not_in input arguments as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.