Simple Past vs. Present Perfect for recently completed actions [duplicate]

@Mari-Lou A has linked to some of the multitude of similar questions on this topic. Whether your particular question can be considered a duplicate of any or most of these (or indeed belongs on ELL), I'll leave others to decide.

I am answering nevertheless because I want to cite an extract from Michael Lewis's The English Verb which offers an alternative way of understanding the usage of the various English verb constructions.

Firstly, Lewis spends some time explaining why he thinks the terms remote past and present retrospective are more helpful for learners than the traditional past simple and present perfect. He then discusses the circumstances in which one or the other form is preferred (p75-78).

The difference between the use of the remote and present retrospective forms causes great difficulty for many learners... .The difference, as we have seen, is that the past simple is essentially factual, remote in time, and relates to a definite state or time in the past; the present retrospective, is, most importantly a present form, essentially grounded in the moment of speaking.

...

Sometimes the language the speaker uses is almost sufficient to guarantee the use of the present perfect. Oh look, someone's opened the window. The use of Oh look places the speaker psychologically very firmly at Now. In these circumstances it is almost certain that the speaker will use a present retrospective. At the same time it is not inevitable. The speaker may...say Oh look, someone opened the window after all. All we can say is if the context is such that the speaker is strongly aware of the moment of speaking, Now, present retrospective forms are common.

As to the present question, it seems clear that in asking where? the speaker is thinking of the shop in which the purchase was made. Since the actual purchase is an event in the remote past, the past simple form is used. I cannot imagine many native speakers asking Where have you bought it? in such a context.

As an aside, Lewis's analysis above explains why the speaker (A) of the original statement uses the present retrospective/perfect. But his further comment applies in this context too. Speaker A might also say: Look! I bought a new hat, influenced by the thought of the purchase event itself.