Marianna -- your recollections of the song are almost spot on. It was written by James Rolmaz in 1888 and the words (in my printed copy) are:

1st verse (of five)
Now how I came to get this hat, 'tis very strange and funny,
Grandfather died and left to me his property and money;
And when the will it was read out, they told me straight and flat,
If I would have his money I must always wear his hat!

Chorus
"Where did you get that hat? Where did you get that tile?
Isn't it a nobby one, and just the proper style?
I should like to have one just the same as that!"
Where'er I go they shout, "Hello! Where did you get that hat?"