File size: 7,507 Bytes
d259c1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{% extends "base.html" %}
{% from "_product_card.html" import product_card %}
{% block title %}{{ title }}{% endblock %}
{% block page_id %}plp{% endblock %}
{% block content %}
<div class="shell">

<nav class="breadcrumbs" aria-label="Breadcrumb">
  {% for label, url in breadcrumbs %}
    {% if url %}<a href="{{ url }}">{{ label }}</a><span class="crumb-sep">/</span>{% else %}<span aria-current="page">{{ label }}</span>{% endif %}
  {% endfor %}
</nav>

<h1 class="plp-title">{{ title }} <span class="result-count">({{ page.total }} item{{ 's' if page.total != 1 }})</span></h1>

{% if not store_selected %}
<p class="store-hint">Prices and pickup shown for <strong>Loop Ace Hardware</strong>. <a href="/store-locator">Choose your store</a> for local availability.</p>
{% endif %}

{% if subcategories %}
<div class="subcat-row">
  {% for sc in subcategories %}
    <a class="subcat-chip {{ 'is-active' if active.leaf == sc.id }}" href="{{ sc.url }}">{{ sc.name }}</a>
  {% endfor %}
  {% if active.leaf %}<a class="subcat-chip clear-chip" href="{{ base_path }}?pageSize={{ page.page_size }}{% if query %}&amp;query={{ query|urlencode }}{% endif %}">Clear</a>{% endif %}
</div>
{% endif %}

<div class="plp-layout">
  <aside class="facet-rail" id="facet-rail" aria-label="Filters">
    <div class="facet-rail-head">
      <span>Filters</span>
      <button class="facet-close" id="facet-close" aria-label="Close filters">&times;</button>
    </div>
    <form method="get" action="{{ base_path }}" id="facet-form">
      {% if query %}<input type="hidden" name="query" value="{{ query }}">{% endif %}
      {% if sort_by %}<input type="hidden" name="sortBy" value="{{ sort_by }}">{% endif %}
      {% if active.leaf %}<input type="hidden" name="leaf" value="{{ active.leaf }}">{% endif %}

      <details class="facet-group" open>
        <summary>Get It Fast</summary>
        <label class="facet-opt"><input type="radio" name="avail" value="pickup-today" {{ 'checked' if active.avail == 'pickup-today' }}> Pickup today</label>
        <label class="facet-opt"><input type="radio" name="avail" value="" {{ 'checked' if not active.avail }}> Everything</label>
      </details>

      <details class="facet-group" open>
        <summary>Brand Name</summary>
        {% for brand, count in facets.brands %}
          <label class="facet-opt"><input type="checkbox" name="brand" value="{{ brand }}" {{ 'checked' if brand in active.brand }}> {{ brand }} <span class="facet-count">({{ count }})</span></label>
        {% endfor %}
      </details>

      <details class="facet-group" open>
        <summary>Price</summary>
        {% for bucket in facets.price_buckets %}
          <label class="facet-opt"><input type="radio" name="price" value="{{ bucket.id }}" {{ 'checked' if active.price == bucket.id }}> {{ bucket.label }}</label>
        {% endfor %}
        <label class="facet-opt"><input type="radio" name="price" value="" {{ 'checked' if not active.price }}> Any price</label>
      </details>

      <details class="facet-group">
        <summary>Special Offers</summary>
        <label class="facet-opt"><input type="checkbox" name="offer" value="sale" {{ 'checked' if active.offer == 'sale' }}> On Sale</label>
      </details>

      <details class="facet-group">
        <summary>Customer Rating</summary>
        <label class="facet-opt"><input type="radio" name="rating" value="4" {{ 'checked' if active.rating == '4' }}> 4 stars &amp; up</label>
        <label class="facet-opt"><input type="radio" name="rating" value="3" {{ 'checked' if active.rating == '3' }}> 3 stars &amp; up</label>
        <label class="facet-opt"><input type="radio" name="rating" value="" {{ 'checked' if not active.rating }}> Any rating</label>
      </details>

      <div class="facet-actions">
        <button class="btn btn-red btn-block" type="submit">Apply Filters</button>
        <a class="btn btn-ghost btn-block" href="{{ base_path }}?pageSize={{ page.page_size }}{% if query %}&amp;query={{ query|urlencode }}{% endif %}">Clear All</a>
      </div>
    </form>
  </aside>

  <section class="plp-results">
    <div class="plp-toolbar">
      <button class="btn btn-ghost filter-toggle" id="facet-open">Filter</button>
      <form method="get" action="{{ base_path }}" class="sort-form" id="sort-form">
        {% for key, value in keep_params.items() if key != 'sortBy' %}
          <input type="hidden" name="{{ key }}" value="{{ value }}">
        {% endfor %}
        {% for brand in active.brand %}<input type="hidden" name="brand" value="{{ brand }}">{% endfor %}
        <label for="sort-select">Sort by</label>
        <select id="sort-select" name="sortBy" onchange="this.form.submit()">
          {% for opt in SORT_OPTIONS %}
            <option value="{{ opt.id }}" {{ 'selected' if sort_by == opt.id }}>{{ opt.label }}</option>
          {% endfor %}
        </select>
        <label for="pagesize-select">Show</label>
        <select id="pagesize-select" name="pageSize" onchange="this.form.submit()">
          {% for size in page_sizes %}
            <option value="{{ size }}" {{ 'selected' if page.page_size == size }}>{{ size }}</option>
          {% endfor %}
          <option value="0" {{ 'selected' if page.page_size == 0 }}>All</option>
        </select>
      </form>
    </div>

    {% if active.brand or active.price or active.offer or active.avail or active.rating %}
    <div class="active-filters">
      {% for brand in active.brand %}<span class="filter-pill">{{ brand }}</span>{% endfor %}
      {% if active.price %}<span class="filter-pill">Price: {{ active.price }}</span>{% endif %}
      {% if active.offer %}<span class="filter-pill">On Sale</span>{% endif %}
      {% if active.avail %}<span class="filter-pill">Pickup today</span>{% endif %}
      {% if active.rating %}<span class="filter-pill">{{ active.rating }}+ stars</span>{% endif %}
    </div>
    {% endif %}

    {% if page['items'] %}
    <div class="product-grid plp-grid">
      {% for p in page['items'] %}
        {{ product_card(p, saved=saved, availability=availability.get(p.sku), show_compare=True, next_url=request.url.path ~ ('?' ~ request.url.query if request.url.query else '')) }}
      {% endfor %}
    </div>
    {% else %}
    <div class="empty-results">
      <h2>No items match those filters</h2>
      <p>Try removing a filter, or <a href="{{ base_path }}?pageSize={{ page.page_size }}{% if query %}&amp;query={{ query|urlencode }}{% endif %}">clear all filters</a>.</p>
    </div>
    {% endif %}

    <div class="compare-bar" id="compare-bar" hidden>
      <span id="compare-label">0 selected</span>
      <a class="btn btn-red" id="compare-go" href="/compare">Compare</a>
      <button class="btn btn-ghost" id="compare-clear">Clear</button>
    </div>

    {% if page.page_count > 1 %}
    <nav class="pagination" aria-label="Result pages">
      {% set qbase = keep_params.copy() %}
      {% for n in range(1, page.page_count + 1) %}
        {% set start = (n - 1) * page.page_size %}
        <a class="page-link {{ 'is-current' if n == page.current_page }}"
           href="{{ base_path }}?{% for k, v in keep_params.items() %}{{ k }}={{ v|urlencode }}&amp;{% endfor %}{% for brand in active.brand %}brand={{ brand|urlencode }}&amp;{% endfor %}pageSize={{ page.page_size }}&amp;startIndex={{ start }}"
           {% if n == page.current_page %}aria-current="page"{% endif %}>{{ n }}</a>
      {% endfor %}
    </nav>
    {% endif %}
  </section>
</div>
</div>
{% endblock %}