Matthew Paul Byford, who was already on a suspended sentence, smashed the front door of Costa Coffee in Wakefield city centre in search of cash.
CCTV footage showed Byford empty the tips cup, then try to break open a charity box. He then took a soft drink and left.
The bottle was found outside the premises and forensically linked Byford.
The 32-year-old was arrested a short time later, wearing the same coat seen on the footage.
Byford told police somebody had just given him the jacket, but gave no comments during his interview. He later admitted a charge of burglary.
The damage to the window cost £500 and the items stolen totalled £11.80.
The court was told that Byford was already subject to a 21-month jail term, suspended for 24 months. The sentence was issued last year when he was convicted of having a dangerous dog out of control.
He originally appeared at Leeds Crown Court in November last year in relation to the Costa break-in, but was told by Judge Penelope Belcher that she would give him six months to tackle his addiction to heroin, cocaine and cannabis before sentencing him.
The court heard this week that he had since enrolled in a detox programme in Manchester, but was kicked out after he left to take drugs.
He then sought help from Turning Point in Wakefield and was now making progress, according to his barrister, Stephen Welford.
Mr Welford said he had moved into supported living in Hyde Park House in Eastmoor and was receiving monthly injections rather than daily doses of methadone, the prescribed heroin substitute.
However, he admitted that Byford was still taking cocaine and cannabis regularly.
Mr Welford said: "He is still doing well. It's not perfect and not ideal, but he seems to have conquered his initial difficulties."
Also in court: Leeds skunk dealer tried to escape onto roof as police raided houseJudge Belcher told Byford: "It's a fine balance but I have come to the conclusion that things are moving in a positive direction."
She gave him a 12-month community order, but warned him that the suspended sentence still remains in place.
"If you come back in front of me with anything serious, you will go into custody, no matter how much progress you have made," she said. "You can't keep offending like this.
"You might think I'm a nice judge but be aware, I'm as tough as any judge. I'm not a soft touch, I'm doing my best to assist you. I'm not afraid to lock people up."
This article was first published by the Wakefield Express.