-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathsearch.liquid
80 lines (74 loc) · 2.97 KB
/
search.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{% paginate search.results by 10 %}
<h1>
{% if search.performed %}
<span class="visually-hidden">{{ 'general.search.heading' | t: count: search.results_count }}:</span>
{{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
{% else %}
{{ 'general.search.title' | t }}
{% endif %}
</h1>
<form action="/search" method="get" role="search">
<label for="Search" class="label-hidden">
{{ 'general.search.placeholder' | t }}
</label>
<input type="search"
name="q"
id="Search"
value="{{ search.terms | escape }}"
placeholder="{{ 'general.search.placeholder' | t }}">
<button type="submit" class="button">
{% include 'icon-search' %}
<span class="icon-fallback-text">{{ 'general.search.submit' | t }}</span>
</button>
</form>
{% if search.performed %}
{% if search.results_count == 0 %}
<p>{{ 'general.search.no_results_html' | t: terms: search.terms }}</p>
{% else %}
<h2 class="visually-hidden">{{ 'general.search.heading' | t: count: search.results_count }}</h2>
<ul>
{% for item in search.results %}
<li>
<a href="{{ item.url | within: collection }}">
{% assign featured_image = item.image | default: item.featured_image %}
{% if featured_image != blank %}
{{ featured_image | img_url: '240x240' | img_tag }}
{% endif %}
<h3>{{ item.title }}</h3>
</a>
{% if item.object_type == 'product' %}
<p>
{% if item.compare_at_price > item.price %}
{% if item.price_varies %}
{% assign sale_price = item.price | money %}
{{ 'products.product.on_sale_from_html' | t: price: sale_price }}
{% else %}
{{ 'products.product.on_sale' | t }}
<span>{{ item.price | money }}</span>
{% endif %}
<span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
<s>{{ item.compare_at_price | money }}</s>
{% else %}
{% if item.price_varies %}
{% assign price = item.price | money %}
<span>{{ 'products.product.from_text_html' | t: price: price }}</span>
{% else %}
<span>{{ item.price | money }}</span>
{% endif %}
{% endif %}
{% unless item.available %}
{{ 'products.product.sold_out' | t }}
{% endunless %}
</p>
{% else %}
<p>{{ item.content | strip_html | truncatewords: 50 }}</p>
{% endif %}
</li>
{% endfor %}
</ul>
{% if paginate.pages > 1 %}
{% include 'pagination' %}
{% endif %}
{% endif %}
{% endif %}
{% endpaginate %}