Hello,
You can simply it a lot
$vendor_id = (int)$variant->product_vendor_id;
$db = JFactory::getDbo();
$query = 'SELECT COUNT(*) FROM `#__hikashop_order` WHERE order_vendor_id = ' . $vendor_id . ' AND order_type = '.$db->Quote('subsale');
$db->setQuery($query);
$orders_count = $db->loadResult();
Afterwards, you might want to just count confirmed orders ; like it is done in HikaShop and HikaMarket.
The idea is to filter on the order_status for invoice statuses : "confirmed" and "shipped".
$query .= ' AND order_status IN (\'confirmed\',\'shipped\')';
Regards,