Using Locksmith and search results

Highlighted
Shopify Partner
1 0 0

I am using Locksmith to create a wholesale section on our website. It works great, except when someone does a search on our search tool on the website for a product that is both wholesale and consumer, both products show up in the search results, even if the customer isn't logged in as a wholesale customer. If you try and click on the wholesale product, it takes you to the Locksmith login page, which is good, but I would love for that product to not even show up in the search results. Any clue how to do this?

It would also be great if the search result count would reflect this as well. Thanks for the advice!

<div class="section-title">
    <h1 class="line-through accent-text">
        <span>{{ search.results.size }} results for <em>&lsquo;{{ search.terms }}&rsquo;</em></span>
    </h1>
</div>

<section id="page-content">
    {% if search.results.size > 0 %} <!-- Display search results -->
        <ul id="search-results">
        {% for item in search.results %}
            {% unless item.metafields.locksmith.active %}
                <li class="result blog {% if item.featured_image %}product{% else %}article{% endif %} {% include 'for-looper' %}">
                <!-- If the result is a product -->
                {% if item.featured_image %}
                    <div class="search-result-product-wrap">{% include 'small-product-item' %}</div>
                {% endif %}
                </li>
            {% endunless %}
        {% endfor %}
        </ul>
    {% endif %}

 

0 Likes
Highlighted
New Member
2 0 0

Having same problem- would love to know the answer. 

0 Likes
Highlighted
New Member
1 0 0

This is the code that I'm using in search.liquid and so far so good...  In my case, in addition to regular customers, I also have "Designer" and "Retailer" customers.  Designers and Retailers get a different price discount from regular price.  

Additional steps

1. Tag customers with "Designer" or "Retailer" or neither.

2. Tag products with "Designer" or "Retailer" or neither.  In other words, I am entering the same product 3 times to reflect the 3 different price points.

 

Here's the search.liquid code snippet...

 {% assign partner = "" %}

 {% if shop.customer_accounts_enabled %}
      {% if customer %}
          {% if customer.tags contains "Designer" %}
            {% assign partner = "Designer" %}
        {% elsif customer.tags contains "Retailer" %}
              {% assign partner = "Retailer" %}
        {% endif %}
      {% endif %}
  {% endif %}  
  
  {% for item in search.results %}  ---->  start to existing for loop
  
    {% if partner == "Designer" and item.tags contains "Designer" %}
          {% assign showit = true %}
      {% elsif partner == "Retailer" and item.tags contains "Retailer" %}
          {% assign showit = true %}
      {% elsif partner == "" %}
          {% if item.tags contains "Designer" or item.tags contains "Retailer" %}
              {% assign showit = false %}
          {% else %}
              {% assign showit = true %}
          {% endif %}
      {% else %}
          {% assign showit = false %}
      {% endif %}    

      {% if showit %}      

        .........existing code in the for loop ........

      {% endif %}

  {% endfor %} --->  end to existing for loop

 

This doesn't solve the bonus question of reporting the correct number in the search results.

Kevin

0 Likes
Highlighted
New Member
1 0 0

Can you help with a Liquid rule that will do the following condition?

Customer has purchased a total quantity of 100 units within 30 days.  This will block the customer for placing any more orders until the 30 days have expired.

Could I see a sample of this code?

0 Likes