Only have search icon on product/shop pages

New Member
1 0 0

Hi,

I have an exlcusive print shop that only registered customers can view. At the moment when someone search nothing appears because the user has to be logged in with an approved account. Is there a way I can only have the search icon appear on the collection/product/shop pages or only appear for customers who are logged in and tagged with 'Approved'?

I am using the Prestige theme.

Thanks in advance

0 Likes
Excursionist
17 2 4
Below is some code I wrote to do this on the Timber theme, you should be able to adjust this to work for your site.


{% if template contains 'collection' or template contains 'product' or template contains 'index' %}
  {% comment %}Check to see what page the customer is on.{% endcomment %}

{% if customer.tags contains 'APPROVED' %}   {% comment %}Check the customers account status and check for APPROVED tag.{% endcomment %} <form action="/search" method="get" class="input-group search-bar" role="search">
{% comment %}<input type="hidden" name="type" value="product">{% endcomment %}
<input type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" class="input-group-field" aria-label="{{ 'general.search.placeholder' | t }}"> <span class="input-group-btn"> <button type="submit" class="btn icon-fallback-text"> <span class="icon icon-search" aria-hidden="true"></span> <span class="fallback-text">{{ 'general.search.submit' | t }}</span> </button> </span> </form>   {% comment %}If customer is logged in and has APPROVED tag this code will fire.{% endcomment %}   {% else %} {% comment %}If customer is not logged in or does not have APPROVED tag do this.{% endcomment %}   {% endif %}   {% endif %}

 

1 Like