Shopify themes, liquid, logos, and UX
Hey guys,
I hope you are doing well.
I am facing an issue, the search.liquid and the search.ajax.liquid code was modified to exclude totally products containing the Press tag. Furthermore, it excludes any products that have a title that contains the word 'wholesale' or products that have a tag 'wholesale' unless a user with a tag 'wholesaler' is logged in. Users with no tag wholesaler' could not find the products with tag or title 'wholesale'.
This has been working perfectly.
The issue I am facing is in when you click on View All results, in the search. For example, if you try to search for 'coaster' the total number of results being displayed is the total per page and not the total. The code had to be modified for it to display the correct total number of results whether the wholesale products are being included or not.
So at the moment, the problem faced is that the Total Count is per page, and not the total number of results (and the total result count has be modified whether the wholesale products should be included or not, and the press should always be excluded from the total result count)
The below is the code for search.liquid
<section data-section-id="search" data-section-type="search"> {%- if search.performed == false or search.results_count == 0 -%} <div class="EmptyState"> <div class="Container"> <h1 class="EmptyState__Title Heading u-h5">{{ 'search.general.title' | t }}</h1> {%- if search.performed -%} {%- assign filtered_terms = search.terms | replace: '*', '' -%} <p>{{ 'search.general.no_results_with_terms' | t: terms: filtered_terms }}</p> {%- else -%} <p>{{ 'search.general.content' | t }}</p> {%- endif -%} <div class="EmptyState__Action"> <form method="GET" action="{{ routes.search_url }}" class="Form"> <input class="Form__Input" type="text" name="q" autocomplete="off" autocorrect="off" aria-label="{{ 'search.general.input_placeholder' | t }}" placeholder="{{ 'search.general.input_placeholder' | t }}" > <input type="hidden" name="type" value="product"> </form> </div> </div> </div> {%- else -%} {%- paginate search.results by 36 -%} <header class="PageHeader"> <div class="Container"> <div class="SectionHeader SectionHeader--center"> <h1 class="SectionHeader__Heading Heading u-h1">{{ 'search.general.title' | t }}</h1> <div class="SectionHeader__Description"> <!-- START, Commented by AC Jan 16, 25, since count is wrong --> {% comment %} {%- assign filtered_terms = search.terms | replace: '*', '' -%} {{- 'search.general.results_with_terms_count' | t: count: search.results_count, terms: filtered_terms -}} {% endcomment %} <!-- END, Commented by AC Jan 16, 25, since count is wrong --> {%- assign filtered_terms = search.terms | replace: '*', '' | strip | escape -%} {%- assign visible_results = 0 -%} {%- for result in search.results -%} {%- if result.object_type == 'product' -%} {%- if result.tags contains 'press' -%} {% continue %} {%- endif -%} {%- if result.tags contains 'wholesale' or result.title contains 'Wholesale' -%} {%- unless customer and customer.tags contains 'wholesaler' -%} {% continue %} {%- endunless -%} {%- endif -%} {%- endif -%} {%- assign visible_results = visible_results | plus: 1 -%} {%- endfor -%} {%- if visible_results > 0 -%} {{- 'search.general.results_with_terms_count' | t: count: visible_results, terms: filtered_terms -}} {%- else -%} {{ 'search.general.no_results' | t: terms: filtered_terms }} {%- endif -%} </div> </div> </div> </header> {%- if search.types contains 'product' -%} <div class="ProductList ProductList--grid Grid" data-mobile-count="2" data-desktop-count="4"> {%- for result in search.results -%} <!-- START ADD of Hiding Wholesale products, AC, Jan 6 --> {%- if result.object_type == 'product' -%} {%- if result.tags contains 'press' -%} {% continue %} {%- endif -%} {%- if result.tags contains 'wholesale' or result.title contains 'Wholesale' -%} {%- unless customer and customer.tags contains 'wholesaler' -%} {% continue %} {%- endunless -%} {%- endif -%} {%- endif -%} <!-- END ADD of Hiding Wholesale products, AC, Jan 6 --> {%- comment %}<locksmith:6876>{%- endcomment %} {%- capture var %}{% render 'locksmith-variables', scope: 'subject', subject: result, subject_parent: search, variable: 'transparent' %}{% endcapture -%} {%- if var == 'true' %}{% else %}{% continue %}{% endif -%} {%- comment %}</locksmith:6876>{%- endcomment %} <div class="Grid__Cell 1/2 1/3--tablet 1/4--lap-and-up"> {%- render 'product-item', product: result, show_labels: true, show_product_info: true, show_vendor: false -%} </div> {%- endfor -%} </div> {%- else -%} <div class="ArticleListWrapper"> <div class="ArticleList Grid Grid--m"> {%- for result in search.results -%} {%- comment %}<locksmith:f287>{%- endcomment %} {%- capture var %}{% render 'locksmith-variables', scope: 'subject', subject: result, subject_parent: search, variable: 'transparent' %}{% endcapture -%} {%- if var == 'true' %}{% else %}{% continue %}{% endif -%} {%- comment %}</locksmith:f287>{%- endcomment %} <div class="Grid__Cell 1/2--tablet 1/3--lap-and-up"> {%- if result.object_type == 'article' -%} {%- render 'article-item', article: result -%} {%- elsif result.object_type == 'page' -%} <article class="ArticleItem"> <div class="ArticleItem__Content"> <h2 class="ArticleItem__Title Heading u-h2"> <a href="{{ result.url }}">{{ result.title }}</a> </h2> <p class="ArticleItem__Excerpt">{{ result.content | strip_html | truncate: 150 }}</p> <a href="{{ article.url }}" class="ArticleItem__Link Link Link--underline"> {{- 'blog.article.read_more' | t -}} </a> </div> </article> {%- endif -%} </div> {%- endfor -%} </div> </div> {%- endif -%} {%- render 'pagination', paginate: paginate -%} {%- endpaginate -%} {%- endif -%} </section>
Please advise, and thank you in advance!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025