It might not need replacing.
Another possibility (beside freon issues) is that the unit is just dusty and dirty. If the metal cooling fins under the filter, or the filter itself is too dirty, there can be a severe lack of airflow. The incoming air is supposed to heat those cold coils, and if there's not enough air, it can't heat it enough to dry the dew and if low enough, that dew will freeze into frost.
Hose everything out, front and back, let it dry overnight in front of a fan. If you can't hose, try this same experiment after a mere vacuuming out. Once cleaned, run it for an hour without any filter. Yes, w/o filter (but only for an hour). If under that best-case airflow situation you still see frost, you need to replace the AC. If there's no frost after an hour, you win; put the filter back in and resume normal operation.
This has worked for me with two different ACs. While with one I admittedly just bought time, it did make it the rest of summer without freezing over. I suspect it had coolant issues as well, but the newly increased airflow was enough to mitigate the issue for a while. The other one was just filthy (got from a smoker?) and it still works, 5 years after I considered ditching it and tried cleaning as a last resort.