78 lines
3.3 KiB
Plaintext
78 lines
3.3 KiB
Plaintext
{%- if predictive_search.performed -%}
|
|
{%- liquid
|
|
assign predictive_products = predictive_search.resources.products
|
|
-%}
|
|
<div class="header__predictive-body">
|
|
<p class="sr-only" data-predictive-count>
|
|
{%- if predictive_products.size > 0 -%}
|
|
{{ 'header.search_status' | t: count: predictive_products.size }}
|
|
{%- else -%}
|
|
{{ 'header.search_empty' | t: terms: predictive_search.terms }}
|
|
{%- endif -%}
|
|
</p>
|
|
{%- if predictive_products.size > 0 -%}
|
|
<ul class="header__predictive-list">
|
|
{%- for product in predictive_products -%}
|
|
<li>
|
|
<a
|
|
class="header__predictive-item"
|
|
id="PredictiveProduct-{{ product.id }}"
|
|
href="{{ product.url }}"
|
|
role="option"
|
|
>
|
|
<span class="header__predictive-media">
|
|
{%- if product.featured_image -%}
|
|
{{
|
|
product.featured_image
|
|
| image_url: width: 120
|
|
| image_tag:
|
|
alt: '',
|
|
widths: '60, 120',
|
|
sizes: '56px',
|
|
loading: 'lazy'
|
|
}}
|
|
{%- endif -%}
|
|
</span>
|
|
<span class="header__predictive-copy">
|
|
{%- liquid
|
|
assign ps_variant = product.selected_or_first_available_variant
|
|
assign ps_on_sale = false
|
|
if ps_variant.compare_at_price > ps_variant.price
|
|
assign ps_on_sale = true
|
|
assign ps_saving = ps_variant.compare_at_price | minus: ps_variant.price | times: 100.0 | divided_by: ps_variant.compare_at_price | round
|
|
endif
|
|
-%}
|
|
{%- if ps_on_sale -%}
|
|
<span class="inline-flex w-fit rounded-[3px] bg-[#f8d5ce] px-1.5 py-[3px] text-[10px] font-medium uppercase leading-none text-[#e35b4c]">{{ 'header.search_sale' | t }} -{{ ps_saving }}%</span>
|
|
{%- endif -%}
|
|
<span class="header__predictive-title">{{ product.title | escape }}</span>
|
|
<span class="header__predictive-price{% if ps_on_sale %} header__predictive-price--sale{% endif %}">
|
|
{%- if ps_on_sale -%}
|
|
<span class="sr-only">{{ 'header.search_sale_price' | t }}</span>
|
|
{{ ps_variant.price | money_without_trailing_zeros }}
|
|
<s class="ml-1 text-[13px] font-normal text-[#a3a3a3]"><span class="sr-only">{{ 'header.search_regular_price' | t }}</span>{{ ps_variant.compare_at_price | money_without_trailing_zeros }}</s>
|
|
{%- else -%}
|
|
{{ product.price | money_without_trailing_zeros }}
|
|
{%- endif -%}
|
|
</span>
|
|
</span>
|
|
</a>
|
|
</li>
|
|
{%- endfor -%}
|
|
</ul>
|
|
<a class="header__predictive-all" href="{{ routes.search_url }}?type=product&q={{ predictive_search.terms | url_encode }}">
|
|
{{ 'header.search_view_all' | t }}
|
|
</a>
|
|
{%- else -%}
|
|
<p class="header__predictive-empty">{{ 'header.search_empty' | t: terms: predictive_search.terms }}</p>
|
|
{%- endif -%}
|
|
</div>
|
|
{%- endif -%}
|
|
|
|
{% schema %}
|
|
{
|
|
"name": "t:header.predictive",
|
|
"settings": []
|
|
}
|
|
{% endschema %}
|