I was having a charging problem with a certified aftermarket cable. Cleaning out the charging port on my phone helped immensely. (I used a toothpick to clean out all the pocket lint, etc.)
Glad to hear your issue is resolved. CNet suggests toothpicks and compressed air (after backing up and with power off) to keep the charging port debris-free ongoing:I started this thread several weeks ago and now I realize the issue for me was with my iPhone X. Ten days ago I upgraded my iPhone X to iPhone 11 Pro and no more problems. I'm almost certain that it was due to some debris inside the iPhone X not allowing it to make a good connection with the lightning cable. Although I tried cleaning it inside, I didn't do a good enough job. Now it's working perfectly with my iPhone 11 Pro.
Good reminder as a maintenance step. Additional suggested cleaning 'tools' above include toothpick and compressed air.I cleaned the lint out of the phone port and took a pencil eraser (lightly) to clean up the end of the lightning cable and things went back to normal. Check both and see if it helps!