Hi there
I’m filtering a large catalogue on the product names.
Some have ‘s’ on the end and some dont
e.g pen or pens
I’d like to be able to search specifically for pens but results show show everything with pen or pens
BALL PEN in Green should also show BALL PENS in Blue
Here’s what I am using at the moment:
This only returns e.g anything with ‘Pen’ in the title or anything with ‘Pens’ in the title.
I’d like it to be either or so if i search for Pen I get items with either Pen or Pens in the title.
Any idea on how to achive this?
Thanks
Justin
Teodor
March 24, 2026, 1:49pm
2
You will need an expression like this:
{{$_GET.searchfilter.endsWith('s').then($_GET.searchfilter.substr(0, $_GET.searchfilter.length() - 1), $_GET.searchfilter)}}
which translates to if $_GET.searchfilter ends with s, then get the value without the last character (this is the s) otherwise use the full $_GET.searchfilter value.
Thank you Teodor, works perfectly!
Just to add more complexity, can it be modified to include split terms in any order?
eg
blue pen
blue pens
pens blue
All give results such as Blue Pens
Justin