Only search for products

zoombie
New Member
2 0 0

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

Replies 2 (2)
PaulNewton
Shopify Partner
3491 233 677

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.

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
zoombie
New Member
2 0 0

Hi Paul,

 Did that, didn't work