Search query with logic AND

Highlighted
Tourist
27 0 0

Hi Team,

I have this code to tweak our search query function in one of our shopify store, but I couldn't make it work in our other store. Can somebody please help me identify the correct parameter that I need to put in replacement for the search-bar and form-control?

Here is our new shopify store.

https://dolphincatalogue.com/search?type=product&q=&options%5Bprefix%5D=last

 

<script>
    function wildcard(str) {
            str = str.split(' ');
    
             for(var i = 0; i < str.length; i++){
              var limit = str.length - 1; 
              if (i < limit) {
                  str[i] = """ + str[i] + "" AND";
              } else if ( i == limit) {
                  str[i] = """ + str[i] + """;
              };                       
             }
          
         
             return str.join(' ');
    }
    
    $('.search-bar').submit(function () {
           alert("stop")
              var searchfield = $('.form-control');
                 searchVal = $searchfield.val();
          
             $searchfield.val(wildcard(searchVal));
    
        });
    </script>

 

0 Likes