You are on page 1of 4

<script

type="application/json"
data-section-type="static-search"
data-section-id="{{ section.id }}">
</script>

{% assign enable_content = section.settings.enable_search_articles_pages %}

{% assign paginate_by = section.settings.results_per_page_range %}

{% paginate search.results by paginate_by %}

{% comment %}
Calculate number of results by type.
{% endcomment %}
{% assign product_count = 0 %}
{% assign article_count = 0 %}
{% assign page_count = 0 %}

{% for item in search.results %}


{% unless item.tags contains 'Wholesale' %}
{% unless customer %}
{% if item.object_type == 'product' %}

{% assign product_count = product_count | plus: 1 %}


{% endif %}

{% if enable_content %}
{% if item.object_type == 'article' %}
{% assign article_count = article_count | plus: 1 %}
{% endif %}

{% if item.object_type == 'page' %}
{% assign page_count = page_count | plus: 1 %}
{% endif %}
{% endif %}
{% endunless %}
{% endunless %}
{% endfor %}

{% comment %}
Calculate the number of result types.
{% endcomment %}
{% assign type_count = 0 %}
{% if product_count > 0 %}{% assign type_count = type_count | plus: 1 %}{% endif
%}
{% if article_count > 0 %}{% assign type_count = type_count | plus: 1 %}{% endif
%}
{% if page_count > 0 %}{% assign type_count = type_count | plus: 1 %}{% endif %}

<div class="productgrid--outer layout--no-sidebar">


<div class="productgrid--wrapper">
{%
include 'breadcrumbs'
%}

<div class="productgrid--masthead">
{%
include 'page-search-form',
enable_content: enable_content
%}
</div>

<div class="productgrid--items">
{% if product_count > 0 %}
{% for item in search.results %}
{% unless item.tags contains 'Wholesale' %}
{% unless customer %}

{% if item.object_type != 'product' %}{% continue %} {% endif %}

{%
include 'product-grid-item',
product: item
%}

{% endunless %}
{% endunless %}
{% endfor %}
{% else %}
<article class="productgrid--no-results">
{% assign title = 'search.general.no_search_performed' | t %}

{% if search.performed %}
{% unless item.tags contains 'Wholesale' %}
{% unless customer %}
{%
include 'search-sanitizer',
search_terms: search.terms
%}

{% assign title = 'search.general.no_results_products_title' | t:


terms: sanitized_terms %}

{% if paginate.current_page > 1 %}
{% assign title = 'search.general.no_more_results_products_title' |
t: terms: sanitized_terms %}
{% endif %}
{% endunless %}
{% endunless %}
{% endif %}

<h2 class="productgrid--no-results-title">
{{ title }}
</h2>

{% if search.performed %}
{% unless item.tags contains 'Wholesale' %}
{% unless customer %}
<a class="productgrid--no-results-button" href="/collections/all">
{{ 'search.general.view_all_products' | t }}
</a>
{% endunless %}
{% endunless %}
{% endif %}
</article>
{% endif %}
</div>

{% if enable_content and search.performed %}


{% unless item.tags contains 'Wholesale' %}
{% unless customer %}
<div class="productgrid--footer">
{%
include 'results-search-content',
title: 'search.general.posts_title',
results: search.results,
results_type: 'article',
results_count: article_count
%}

{%
include 'results-search-content',
title: 'search.general.pages_title',
results: search.results,
results_type: 'page',
results_count: page_count
%}

</div>
{% endunless %}
{% endunless %}
{% endif %}

{% include 'pagination' %}
</div>
</div>
{% endpaginate %}

{% schema %}
{
"name": "Search results",
"class": "search--section",
"settings": [
{
"type": "range",
"id": "results_per_page_range",
"label": "Results per page",
"min": 24,
"max": 48,
"step": 12,
"default": 24
},
{
"id": "enable_search_articles_pages",
"type": "checkbox",
"label": "Show blog posts and pages in search results",
"default": true
}

]
}
{% endschema %}