B2B Site - Show/Hide Collections to Customers with certain tags

Hi there,

I know this question has been asked before but I can’t seem to find a complete solution that not only hides/locks the collection from certain customers but also removes that particular collection tab from the main menu.

Is this possible and how would I go about achieving this?

Cheers

Hi,

The theme being used is Minimal.

Hi @Costa123 ,

With your descriptions, firstly these collections are only visible when the customer has to login? If only check with tag, it will have cases where the customer is not logged in and everything is still visible.

So can you confirm this first? I will guide you specifically with the code.

Hi @LitCommerce ,

Thanks for replying. So this is the first time I’m setting up a storefront. I thought I’d give you some extra detail so you understand what I’m trying to achieve. It is a B2B site and the goal is to have the customer login/register for approval and then once they have access they will have certain customer tags assigned to them. These tags will identify which collections that particular customer will have access to.

Currently the collections are visible even if the customer is not logged in. This is something I need to change but can’t seem to find this within the theme setup, I am presuming this needs to be done within the code?

What code? Please

Hi @Costa123 ,

If you want the client to need to login before accessing, it will be a complicated requirement and you need to change a lot with the code. You can use this code to check login:

{% if customer %}
{% endif %}

If you are new, I recommend you to hire an expert to set everything up, as it needs to change a lot with the code.

Hope it helps!

Hi @LitCommerce ,

Thanks for replying back. I have now amended the code so that a customer must login before accessing any collections. Now this is the bit I’m a little unsure on. I need to be able to only let particular customers access certain collections based on customer tags.

Hi @Costa123 ,

You can use the following code:

{% if customer.tags contains 'customer tag' and collection.title == 'collection title' %}
{% endif %}

It will help set conditions so that customers with the right tag and correct collection name can go to the collection.

If it helped you solve your issue, please mark it as a solution. Thank you and good luck.

Hi @LitCommerce ,

Thanks for the code, appreciate it. I have managed to implement this into the collections-template and it does work which is great.

The way my site is setup I have a dropdown menu in the nav-bar which takes a customer to a specific collection, how easy would it be to hide these depending on customer tags? Currently these dropdown menus remain even when the collection is not accessible. Any help again would be great.

Thanks

Hi @Costa123 ,

Can you send me the code of header.liquid file, I will help you to check it


  

    
  

  
    
      
      {{ 'layout.cart.cart' | t }} {{ cart.item_count }}
    
  

{% if customer %}

{% endif %}

{% schema %}

Hi @LitCommerce ,
Please see the code from the header.liquid file.
Thanks


  

    
  

  
    
      
      {{ 'layout.cart.cart' | t }} {{ cart.item_count }}
    
  

{% if customer %}

{% endif %}

{% schema %}

Hi @LitCommerce ,

Please see the code for the header.liquid template.

Thanks


  

    
  

  
    
      
      {{ 'layout.cart.cart' | t }} {{ cart.item_count }}
    
  

{% if customer %}

{% endif %}

{% schema %}

Hi @LitCommerce ,
Please see the header.liquid template.
Thanks


  

    
  

  
    
      
      {{ 'layout.cart.cart' | t }} {{ cart.item_count }}
    
  

{% if customer %}

{% endif %}

{% schema %}

Hi @LitCommerce ,

Please see the code for the header.liquid template.

Thanks

Hi @LitCommerce ,

Please see the header.liquid code.

Thanks

{% if request.page_type == 'index' %}

{% else %}
{% endif %} {% if section.settings.logo %} {% capture image_size %}{{ section.settings.logo_max_width | escape }}x{% endcapture %} {%- assign img_url = section.settings.logo | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%} {% capture logo_alt %}{{ section.settings.logo.alt | default: shop.name }}{% endcapture %}
{{ logo_alt | escape }}
{% capture image_size %}{{ section.settings.logo_max_width | escape }}x{% endcapture %} {{ logo_alt | escape }}
{% else %} {{ shop.name }} {% endif %} {% if request.page_type == 'index' %}

{% else %}
{% endif %}
{% if section.settings.show_announcement or shop.customer_accounts_enabled %}
{% if section.settings.show_announcement %} {% if section.settings.announcement_link != blank %} {% endif %}

{{ section.settings.announcement_text | escape }}

{% if section.settings.announcement_link != blank %}

{% endif %}
{% endif %}

{% if shop.customer_accounts_enabled %}

{% if customer %}
{% capture first_name %}{{ customer.first_name }}{% endcapture %}
{{ ‘layout.customer.logged_in_as_html’ | t: first_name: first_name }} · {{ ‘layout.customer.log_out’ | t | customer_logout_link }}
{% else %}
{{ ‘layout.customer.sign_in’ | t | customer_login_link }}
{{ ‘layout.customer.or’ | t }}
{{ ‘layout.customer.create_account’ | t | customer_register_link }}
{% endif %}

{% endif %}


{% endif %}

{% include ‘search-bar’ %}
{% if customer %}


{{ ‘layout.cart.cart’ | t }} {{ cart.item_count }}

{% endif %}

{{ 'layout.navigation.mobile_menu' | t }}

{% if customer %}

{% include 'search-bar' %} {% include 'mobile-nav' %} {% include 'site-nav' %}
{% endif %}

{% schema %}

Hi @Costa123 ,

Go to snippets > site-nav.liquid file, find ‘childlink in link.links’ and add code here:

Code:

{% if customer.tags contains 'customer tag' and childlink.title == 'collection title' %}
{% endif %}

Hope it helps!

Hello,

I have been searching this site trying to find some help customising my main collections grid so that only collections that a customer has access to are visible. I have already created a couple of collections that are only availbale to 1 customer each, they work find if a customer tries toview a collection they dont have access to they are redirected to another page which tells them they dont have access etc. howeer what i woudl like to try and do is have the main collections page ony show the collections that they have access to so they cant even click on them to get to the page that tells them they done have access. Your post here seems to be the closest thing i can find, could you help me please? :slightly_smiling_face: