Add a parameter to the search function

Rydior
New Member
4 0 0

Hello,

So I am using the Flow theme on shopify, it uses the basic search, code posted below of the search,

Standard Search URL - https://www.mywebsite.com/search?type=product&q=Shirt

What I want - https://www.mywebsite.com/search?type=product&q=tag%3AShirt

I essentially what to put TAG: infront of the users search so that it only searches for tags.

No matter what I do, I cant seem to get the parameter tag: after the q=.

I tried change the value through jquery after user submits, but that doesnt work. I added the tag: on the value input but that doesnt work as it will keep adding tag: on each submission making it tag:tag:tag:search.term

I added an if statement to only put tag: in value if it's not there, but for some reason that wont work on first try

So im at a loss what to do, I want the user to only show values of searchs on tags and I need to do this by adding tag: infront of their search term, how do i do this?

 

<form action="{{ routes.search_url }}" method="get" class="input-group search-bar" role="search">
  <input type="hidden" name="type" value="product">
  <input type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" class="input-group-field" aria-label="{{ 'general.search.placeholder' | t }}">
  <span class="input-group-btn">
    <button type="submit" class="btn icon-fallback-text">
      <i class="fa fa-search"></i>
      <span class="fallback-text">{{ 'general.search.submit' | t }}</span>
    </button>
  </span>
</form>

 

 

0 Likes