Недавно я установил sh b2b-платформу shopify, где все мои продукты помечены как «оптовая торговля».
Мне удалось опустить оптовый тег при нажатии на кнопку поиска, но не в раскрывающееся меню, которое мгновенно загружает результаты.
Пожалуйста, взгляните на мой код:
{% assign grid_results = false %}
{% assign respond_js_secret_key = shop.domain | md5 %}
{% unless search.terms == respond_js_secret_key %}
{% paginate search.results by 10 %}
<div class="theme-default-margin search-page">
<div class="container">
<div class="row">
<div class="col-lg-10 offset-lg-1 col-md-12">
{% if search.performed %}
{% if search.results_count == 0 %}
<h4 class="text-center page-search-title">{{ 'general.search.no_results_html' | t: terms: search.terms }}</h4>
{% else %}
<h4 class="text-center page-search-title">{{ 'general.search.results_for_html' | t: terms: search.terms }}</h4>
{% endif %}
{% else %}
<h4 class="text-center page-search-title">{{ 'general.search.title' | t }}</h4>
{% endif %}
<div class="page-search-bar">
<form action="/search" method="get" class="page-search-form" role="search">
{% comment %}<input type="hidden" name="type" value="product">{% endcomment %}
<input id="searchInput" type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" aria-label="{{ 'general.search.placeholder' | t }}">
<button type="submit">
<i class="ion-ios-search-strong"></i>
</button>
</form>
</div>
{% if search.performed %}
<div data-sectionId="{% if section.id %}{{section.id}}{% endif %}" data-settings='{% if section.settings %}{{section.settings | json}}{% endif %}' id="gf-products" class="search-list">
{% for item in search.results %}
{% unless item.tags contains 'wholesale' %}
<script type='application/json' class='bold-product-json'>{{ item | json }}</script>
{% include 'product-search-item' %}
{% endunless %}
{% endfor %}
</div>
{% endif %}
{% if paginate.pages > 1 %}
<div class="page-search-pagination pt-30">
{% include 'pagination' %}
</div>
{% endif %}
</div>
</div>
</div>
</div>
<script>
document.getElementById("searchInput").focus()
</script>
{% endpaginate %}
{% else %}
{% include 'respond' %}
{% layout none %}
{% endunless %}
В частности, я добавил в этот код, чтобы опустить результаты поиска «оптом»:
{% for item in search.results %}
{% unless item.tags contains 'wholesale' %}
<script type='application/json' class='bold-product-json'>{{ item | json }}</script>
{% include 'product-search-item' %}
{% endunless %}
{% endfor %}
Вот изображение того, о чем я говорю
В библиотеке есть еще один файл AJAX, который, как я думаю, может относиться к этому, но после внесения изменений это не повлияло на результаты.