This article explains what might be causing your iPhone to not charge and what steps you can take if the problem is with the charging port.
Fast DIY iPhone Charger Port REPAIR – Not Charging, Loose Connection – 6, 7, 8, XS, XR, 11, 12 + iPad
Common reasons why an iPhone won't charge:
If your iPhone is set to Optimized Battery, turn this feature off to allow your iPhone to charge again.
If you're certain (or at least fairly certain) that your iPhone's inability to charge is a result of issues with the charging port, here's what you can do to troubleshoot the problem: