Two common reasons the charging port needs to be replaced are easily prevented. Wrapping the cable around the phone or holding it a certain way to charge is a clear sign the charging port has considerable debris buildup. Usually pocket lint from cotton blue jeans. Fake Apple cables WILL fry things as well.
The Dock Assembly performs many functions including: Charging port, Primary Microphone, Headphone Jack, Home Button, Cellular Antenna, and Loudspeaker pass-through.
iPhone X/XR/XS Dock Assembly - $95
iPhone 7/8/Plus Dock Assembly - $75
iPhone 6/6S/Plus Dock Assembly - $50
iPhone 5S/5C/5 Dock Assembly - $50