Hi there,
yes, it can be a workaround because two orders are created together and the ID are consecutive.
By the way you have to know that exists a method inside the class YITH_Orders that provides the suborder, using the parent order ID.
public static function get_suborder( $parent_order_id = false, $check_created_via = false ) {
$suborder_ids = array();
if ( $parent_order_id ) {
global $wpdb;
$parent_ids = array( absint( $parent_order_id ) );
while ( $parent_ids ) {
$parent_list = implode( ',', $parent_ids );
$parent_ids = $wpdb->get_col(
$wpdb->prepare( "SELECT ID
FROM {$wpdb->posts}
WHERE post_parent IN ({$parent_list})
AND post_type=%s",
'shop_order'
)
);
$suborder_ids = array_merge( $suborder_ids, $parent_ids );
}
}
if( $check_created_via ){
foreach( $suborder_ids as $k => $suborder_id ){
$suborder = wc_get_order( $suborder_id );
$created_via = $suborder->get_created_via();
if( 'yith_wcmv_vendor_suborder' != $created_via ){
unset( $suborder_ids[ $k ] );
}
}
}
return apply_filters( 'yith_wcmv_get_suborder_ids', $suborder_ids, $parent_order_id );
}