Have you regularly been using the phone until the battery drops below 40%? If so, the battery is probably shot and has to be replaced. (Lithium batteries are not deep-discharge devices.)
If not, and with the diagnosis that the cable sometimes gets hot, I'd suspect the charging circuitry in the phone (which means a trip to a repair shop).