- Import your products and add a custom field "_old_id" containing the import element {id[1]}, like this: https://d.pr/i/pLxdiJ.
- Import your orders and use the following custom PHP function in the 'Product SKU' field (it should look like this https://d.pr/i/8ijjl4):
//Usage example: [my_connect_orders({productid[1]})]
function my_connect_orders( $product_id ) {
global $wpdb;
$query = 'SELECT `post_id` FROM `' . $wpdb->prefix . 'postmeta` WHERE `meta_key` = "_old_id" AND `meta_value` = "' . $product_id . '"';