You have done a great job of troubleshooting the issue. Now it's time to have a technician take a look at it. Even if your iPhone is no longer under warranty, you can still get it serviced for an out-of-warranty fee.
There is no need to be looking to have it replaced.
This page will get you started, and you can get an estimate also:
iPhone Repair & Service
You'll want to back up your iPhone using a computer before you bring it in, so not to lose any of your data:
How to back up your iPhone, iPad, and iPod touch
Choose either Mac or PC to get started.
If you've been backing up with iCloud before the Wi-Fi stopped working, here's how to see if and when a iCloud backup was made:
2. Tap your name
3. Select iCloud
4. Scroll down and tap iCloud Backup
5. "Last successful backup" will give you the date/time
Locate backups of your iPhone, iPad, and iPod touch for more info.