Top

Symmetry Theme Search Box Modification

The following will remove the duplicate and hidden product from the search dropdown, and prevent the duplicate the hidden products from showing up in the search quantities.

 

Replace search.json.liquid with this:

{% layout none %}
{% comment %} Inspired by: http://ecommerce.shopify.com/c/ecommerce-design/t/diy-implementing-autocomplete-with-search-144104 {% endcomment %}
{% paginate search.results by 10 %}
 {% capture output %}
{% assign first = 1 %}
 {% for result in search.results %}
{% if result.metafields.inventory.ShappifyHidden == "true" %}{% else %}
      {% if first == 1 %}{% assign first = 0 %}{% else %},{% endif %}
        {% assign resultURL = result.url %}
        {% assign thumbURL = result.images[0] | product_img_url: 'thumb' %}

        {"title":"{{ result.title | replace: '\\', '\\\\' | replace: '"', '\\"' | replace:  '/','\\/' }}",
           "url":"{{ result.url   | replace: '\\', '\\\\' | replace: '"', '\\"' | replace:  '/','\\/' }}",
         "thumb":"{{ thumbURL     | replace: '\\', '\\\\' | replace: '"', '\\"' | replace:  '/','\\/' }}",
            "id":{{result.id}} }
    {% endif %}{% endfor %}
{% endcapture %}

{% comment %} Output the json object {% endcomment %}
{"results_total":{{paginate.items}},"results":[{{ output | strip_newlines }}]}
{% endpaginate %}

Comment out this line in search.liquid:

<h5>We found {{ paginate.items }} {{ paginate.items | pluralize: 'result','results' }}</h5>

Remove (' + data.results_total + ') from this line in main.js.liquid:

$resultsBox.append('<a href="' + linkURL + '" class="note">See all results (' + data.results_total + ')</a>');

Have more questions? Submit a request