Hi there,
I’d like to hide footer links from those who are not logged in. Is there a way to make them only visible to logged in users?
Here is the site: https://wholesale.harrisvilledesigns.com/
A user wants to hide specific footer links from visitors who aren’t logged in to their Shopify Plus store.
Proposed Solution:
Another participant confirms this is achievable using Liquid conditional logic, though notes the syntax can be tricky due to limited control over operation order with and/or statements.
Implementation Approach:
show_link variable to control visibilityshow_link = false) when the customer is not logged in AND the link matches certain handlesStatus:
Pseudo code examples were provided but noted as untested. The discussion appears to offer directional guidance rather than a finalized solution. The code snippets show two potential approaches with varying levels of compactness.
Hi there,
I’d like to hide footer links from those who are not logged in. Is there a way to make them only visible to logged in users?
Here is the site: https://wholesale.harrisvilledesigns.com/
This is definitely doable. The conditional logic can be a little tricky to get your head around—especially since liquid doesn’t provide much conrol over order of operations with and/or in if statements.
Here’s some potential speudo code showing how you might do it. This has not been tested so I am not 100% sure if it’s exactly right but hopefully it points you in the right direction.
{%- for link in menu.links -%}
{%- liquid
assign show_link = true
if link.handle == 'x' or link.handle == 'y' or link.handle == 'z'
unless customer
assign show_link = false
endunless
endif
-%}
{%- if show_link -%}
<li>…</li>
{%- endif -%}
{%- endfor -}
You could also tighten it up to be like this but it’s a little harder to understand the code:
…
if customer == false and link.handle == 'x' or link.handle == 'y' or link.handle == 'z'
assign show_link = false
endif
…