Hide product link in Liquid when unavailable in B2B catalog

How can I determine in Liquid if a product is not available for a certain B2B customer location? I need to hide the product link set from section block settings when it’s not accessible.

The product object in the block settings link.object is still available for that customer, but the product is not in their B2B catalog.

Unless I’m mistaken, this is natively handled under the hood and you won’t be returned the product, for example on the collection page if the product isn’t part of the customers assigned catalog.

Hi Luke,
The product is indeed hidden on the collection page when cycling through all products. However there’s a button in a section on the homepage that links to a product unavailable to the current customer.
The button’s url is set through a link setting in the theme editor. Therefore I need to add an if statement around the button to control its visibility.

Hey Brecht,

I believe you can change the context to B2B in the theme customiser and then hide that button.

Hi Rishi,
The button needs to be hidden for a specific catalog / company location, which can’t be done through the theme editor. It’s worth noting that the entire website is a B2B store.

It would be nice if Shopify would just make the link.object of a product link empty when the product is not available to a customer.