Allardyce had only
The club confirmed several offers for a striker on transfer deadline day had failed and a move for Carlton Cole, who left West Ham at the end of his contract in June, was also called off after the England forward could not prove his fitness.
Because Petric was a free agent he was not constrained by the closing of the transfer window and will join up with his new team-mates relishing the chance to get back to playing in England.
"I'm very happy, excited and looking forward to training with the team and to the first game," Petric told the club's official website.
"I'm happy to be back in the Premier League, because it's a fantastic league and I'm really looking forward to being part of this team and this club. There are a lot of good players here and I'm happy to be part of such a good team and I hope we can all celebrate my first goal for West Ham as soon as possible."
Petric confirmed his former Hamburg team-mate Guy Demel had sold the club to him, and the new recruit knows from his own experience what West Ham offer.
"I didn't speak to Sam [Allardyce] until today but I've heard a lot about him and I spoke to Guy Demel, who I know from my time at Hamburg and I'm sure I'll have a good time here," said Petric.
"I remember playing at West Ham last year and it was a very tough game for us at Fulham. I think we lost 3-0! It's not easy to come here [as the away side] and take points away."