Chosen Solution
11” macbook air, 2015. The power adaptor occasionally stops charging. Battery goes flat. Needs a lot of wiggling of the connector into the laptop to get it to start charging again. The orange and or green lights can be on, but the laptop isn’t charging.
Commonly one would think they have a bad cord. But since you indicated you have to wiggle in the connection that would suggest that you either have some dirt or something in the connection, the end of the power cord itself was bad but I would moreso believe the connection inside the laptop was loose or broke a solder connection. Check the cord with a voltmeter while wiggling it to see if your voltage goes off and on to confirm. Inspect connection they do often collect dust. You’ll have to open up the laptop to see if you have a broken solder point or if the connection is loose.
Follow this Apple T/N Apple Portables: Troubleshooting MagSafe adapters. You may need a new charger do make sure you get a real Apple unit OEM MagSafe Chargers vs Cheap Imposters: Teardown for Truth Within your system is the DC-In board, in this series its part of the I/O board if the contacts look bad I would recommend replacing it MacBook Air 11" (Mid 2013-Early 2015) I/O Board and here’s the guide to put it in MacBook Air 11" Early 2015 I/O Board Replacement