'They had been shopping for a long time' can also be translated with the help of the word 'уже' - 'already' - Они уже долго ходили по магазинам (и всё еще продолжали). In this sentence the Russian equivalent of already would help better communicate the meaning that the still were shopping.