Creating a conditional link back in FrameMarket

Hi Folks,

In a multisite install with FrameMarket, GridMarket and MarketPress I have a global site search from the parent site to shopping carts in sub sites.

Also products from the sub sites appear on the parent site.

Clicking a link from a search result or one of a product on the parent site takes a visitor to one of the sub sites (as is normal).

However the sub sites are also used as shopping carts that are linked from other external websites that are not in multisite.

So if a visitor arrives at a sub site shopping cart from the external link, I don't want any links visible that would lead to the parent site.

However if the visitor arrives at the sub site cart from a link off the parent site, I'd like to display a "Back to Parent Site" button of sorts that they could use to get to the parent site (without having to use the browser's back button).

Does anyone have any ideas on how best to do this?