Is it possible to hide search bar based on customer tag in Dawn 2.0?

Solved

Is it possible to hide search bar based on customer tag in Dawn 2.0?

Smeelah
Navigator
374 1 116

I have a wholesale section in my website and when a customer is tagged 'wholesale' they can only view the wholesale menu. However, the search bar is still visible and it only returns 'retail' results, so I would prefer to hide it. 

I'm happy to edit the code if anyone has a suggestion on how to do that!

TIA:)

Dawn 15.0.2

Accepted Solution (1)

Sweans
Shopify Partner
429 89 126

This is an accepted solution.

Hi @Smeelah ,

To hide the search bar for customers tagged as 'wholesale', follow these steps:

1. Go to Online Store > Themes.

2. Click on Actions next to your current theme and select Edit code.

3. In the code editor, find the header.liquid file, typically located under the Sections folder.

4. Locate the header-search by searching for it in the header.liquid file.

5. Replace the existing code for the search bar with the following:

   

 

      {% unless customer.tags contains 'wholesale' %}
        {% render 'header-search', input_id: 'Search-In-Modal' %}
      {% endunless %}

 

Refer Screenshot:

Sweans_0-1722572241614.png

5. Click Save to apply the changes.

 

This code ensures that the search bar is only displayed to customers who are not tagged as 'wholesale'. For customers tagged as 'wholesale', the search bar will be hidden.

 

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

View solution in original post

Replies 2 (2)

Sweans
Shopify Partner
429 89 126

This is an accepted solution.

Hi @Smeelah ,

To hide the search bar for customers tagged as 'wholesale', follow these steps:

1. Go to Online Store > Themes.

2. Click on Actions next to your current theme and select Edit code.

3. In the code editor, find the header.liquid file, typically located under the Sections folder.

4. Locate the header-search by searching for it in the header.liquid file.

5. Replace the existing code for the search bar with the following:

   

 

      {% unless customer.tags contains 'wholesale' %}
        {% render 'header-search', input_id: 'Search-In-Modal' %}
      {% endunless %}

 

Refer Screenshot:

Sweans_0-1722572241614.png

5. Click Save to apply the changes.

 

This code ensures that the search bar is only displayed to customers who are not tagged as 'wholesale'. For customers tagged as 'wholesale', the search bar will be hidden.

 

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

Smeelah
Navigator
374 1 116

Thank you! It works perfectly.