Shopify themes, liquid, logos, and UX
Hello there,
I'm using the Dawn theme, I want to make the search function to be only searching for products. After some research, I've found this code
<input type=hidden name=type value="product">
I've put it in this section of main-search.liquid
<form action="{{ routes.search_url }}" method="get" role="search" class="search">
<input type=hidden name=type value="product">
<div class="field">
<input
class="search__input field__input"
id="Search-In-Template"
type="search"
name="q"
value="{{ search.terms | escape }}"
placeholder="{{ 'general.search.search' | t }}"
{%- if settings.predictive_search_enabled -%}
role="combobox"
aria-expanded="false"
aria-owns="predictive-search-results-list"
aria-controls="predictive-search-results-list"
aria-haspopup="listbox"
aria-autocomplete="list"
autocorrect="off"
autocomplete="off"
autocapitalize="off"
spellcheck="false"
{%- endif -%}
>
The code works half of the time. When searching using the search form in the header, it return results for everything. But on the search results page, there's another search form, if I search from that search form, the results is for product only.
Here's my website
www.ikuono.com - try searching "high top sneaker"
Thank you 🙂
Improve <input type=hidden name=type value="product">
to
<input type="hidden" name="type" value="product">
Helps remove the chance of parse errors
And try it again.
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
Hi Paul,
Did that, didn't work 😞
+1!!!
Can't get this to work in Dawn theme main-search.liquid code
Shopify .dev Docs don't have proper documentation for filtering search results on OS 2.0 Themes.
@zoombie I see you got this working on your site! Mind sharing your knowledge? Never mind, I see the page results at the bottom of the search now 😞
🙏🏼
@zoombie If you add the same code to the Header.liquid file, that will solve your problem.
Search in header.liquid for the same function (form action...) and add the same code Paul provided.
I've been trying to figure this out for 2 days... that solved it for me.
Hi all, the code has worked on Desktop view but not Mobile. Does anyone have a solution to fix this?
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024