Lee Newby was also involved in a robbery in which a man was repeatedly punched before having his bicycle stolen.
Leeds Crown Court heard Newby took part in both offences in Featherstone on August 10 last year.
David Bradshw, prosecuting, said Newby and another man targeted Amigos, on Station Lane, as the owner was getting ready to close for the evening at 11.55pm.
The two men rushed into the premises and Newby's accomplice threatened the victim with a knife.
Newby, 33, picked up the cash till try and the pair ran off with it. The till tray contained around £500.
Mr Bradshaw said a police dog helped recover the till tray a short distance away and it was found to contain Newby's fingerprint.
The defendant was also identified from CCTV footage from the area around the time of the incident.
Earlier in the day, at 5.25pm, Newby and another man targeted a young man on Pontefract Road as he was riding his bicycle.
Newby's accomplice punched the victim in the face multiple times and accused him of informing the police on him.
Newby pulled the bike from the victim and rode off on it.
Newby, of Whinney Lane, Streethouse, pleaded guilty to two offences of robbery.
He has previous convictions for assault, vehicle theft, harassment and drugs offences.
Andrew Stranex, mitigating, said Newby's offending was linked to his addiction to drugs.
He said Newby had been sleeping rough at a railway station at the time of the offending but had been working as a landscape gardener.
Mr Stranex said: "He's motivated to knuckle down.
"He knows he is going to get a prison sentence today."