stop by (somewhere) on the way (to somewhere)

This means to quickly go to a place before continuing to your final destination.

You usually indicate the destination with "to":

on the way to the airport

But "there" and "here" are exceptions to the rule. They don't use "to":

Was there any traffic on the way here?

This phrase appears in these lessons: