Partial Word Search Feature

Tourist
12 1 0

Hi,

 

We'd like the search function on our website www.liquidispose.co.uk to match partial words. We understand that this may require some Java Script. Can anyone help?

 

Thanks, Lucy.

0 Likes
Shopify Partner
1838 173 601

Hello Lucy,

 

Searching for partial words is already supported if you use the asterisk character * e.g. cu* will find cup, cups etc.

 

If you want to make this the default behaviour when searching for terms, you will need Javascript (as you noted) to append that asterisk to the search term from the input field.

 

Would that be sufficient for your needs?

I turn coffee in to code - since 1998
0 Likes
Tourist
12 1 0

Hi Karl,

 

Thank you, yes, that's what we need!

 

Thanks, Lucy.

0 Likes
Shopify Partner
1838 173 601

Well quick & dirty would be to add it to the search form element directly on its onsubmit attribute as so

 

onsubmit="var s=$('input[type=search]');s.val(s.val()+'*')"

 

That should be on both search forms - the one in sidebar and search page.

 

Ideally though it would be much more neatly tucked away in the theme's theme.js.liquid.

 

Hope this helps!

I turn coffee in to code - since 1998
0 Likes
Tourist
12 1 0

This worked perfectly, thanks!

0 Likes
New Member
1 0 1

Hello, Karl! what about middle terms, e.g: The product code is R4800 and I'd like it to show on the results when I look for 800. Thanks

1 Like
Shopify Partner
2 0 0

I am also looking for this functionality. Have you figured this out?

0 Likes