Tagged Products not showing in search for tagged customers

Haydn_Griggs
New Member
8 0 0

Hi,

Apologies if this is the incorrect forum for this but cant seem to fing the answer anywhere else.

I want to have only tagged products showing in the search bar results for customers who contain the tag. 

The products do not show for customers without the tag, however, they are also not showing for the customers who do have the tag?

I have edited the search.liquid with the following, can anyone see what may be wrong? 

{% for item in search.results %}
           {% unless item.tags contains 'Wholesale' %}
        
              
           {% if item.object_type == 'product' %}
              {% assign product = item %}
              {% include 'product-grid-item' %}
            {% else %}
              <div class="grid__item grid-search large--one-third medium--one-half">
                <div class="grid-search__page">
                  <a href="{{ item.url }}" class="grid-search__page-link">
                    <span class="grid-search__page-content">
                      <span class="h4 text-center">{{ item.title }}</span>
                      {{ item.content | strip_html | truncatewords: 60 }}
                    </span>
                  </a>
                </div>
              </div>
            {% endif %}
            {% endunless %}
             {% endfor %}

Essentially, I want my wholesale products to show up when a wholesale customer logs in but at present the non-wholesale items are showing in the search.

Ant help would be greatly appreciated,

 

Many thanks

Andy

 

0 Likes
Haydn_Griggs
New Member
8 0 0

This is the search.liquid at present

0 Likes
Mandelbrotian
Shopify Partner
132 1 19

Hi Haydn,

You can filter based on a customer tag with

{% if customer and customer.tags contains 'Wholesale' %}
  // print wholesale items
{% else %}
  //print non wholesale items
{% endif %}

Cheers,

Elliott

Feeling a bit lost? Contact elliot@mandelbrotian.com for help with theme setup, alterations, custom functionality, and app development.
0 Likes
Jason
Shopify Expert
10292 145 1946

You can simplify the above to just say:

{% if customer.tags contains 'Wholesale' %}

You don't need to check for the customer first. If you can see the tags, they are logged in.

That sort of approach can be a little messy on its own though. Let's say you have a search that returns 100 items. If your search page shows 50 items per page, and the first 50 are all for wholesale only - a non wholesale customer would see a blank page. That'a not super friendly.

There's ways around that, but be aware that you may need to extend the idea further.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Haydn_Griggs
New Member
8 0 0

Hi,

Thanks both for getting back to me.

I have tried each of the edits, however it foesnt seem to work? 

When I log in with an account that contains the 'wholesale' tag, I do see the wholesale catalogue but when using the search for a product, only the retails itsems are returned? 

Do you know how I can have it so that if a wholesale customer logs in, they see the 'wholesale' catalogue and also the search ony returns the 'wholesale' products?

Any help is greatly appreciated,

Many thanks

0 Likes