Plugin Author
ILLID
(@mihail-barinov)
Hello,
Please use following code snippet
add_filter( 'aws_search_query_array', 'my_aws_search_query_array' );
function my_aws_search_query_array( $query ) {
global $wpdb;
$regex = "/term_source = 'sku' AND term LIKE '%(.*?)%'/is";
$query['relevance'] = preg_replace( $regex, "term_source = 'sku' AND term LIKE '$1%'", $query['relevance'] );
$regex = "/term_source = 'sku' AND term LIKE '{.*?}(.*?){.*?}'/is";
$query['relevance'] = preg_replace( $regex, "term_source = 'sku' AND term LIKE '$1%'", $query['relevance'] );
return $query;
}
You need to add it somewhere outside plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Also after adding this code you will need to go to the plugin settings page and click ‘Clear cache’ button.
Regards
How can i limit the SKU search to only lets say the first 3 characters?
Plugin Author
ILLID
(@mihail-barinov)
So, if user type inside search form, for example, 74303818, you want to search only for 743?
No 🙂 lets say there are the following products 70/284821, 12/027028, 20/703810 (all of them have 70) and the user types 70 inside the search form, then i want that only 70/284821 is shown instead of all of them. So for SKUs i want that only the first 3 characters are relevant.
Plugin Author
ILLID
(@mihail-barinov)
Well code snippet that I write previously will works exactly the same way – will show only 70/284821 when searching for ’70’.
Here is an image of what i mean https://ibb.co/0X4p2w3
I added the snippet and clicked on ‘Clear cache’ button
Plugin Author
ILLID
(@mihail-barinov)
You enable only search for product SKU?
Are you sure than other search sources are disabled?
Title Yes
Content No
SKU Yes
Excerpt No
Category No
Tag Yes
Attributes No
Taxonomies No
Custom Fields No
Plugin Author
ILLID
(@mihail-barinov)
Can you give me the link where I can test this search form?
Plugin Author
ILLID
(@mihail-barinov)
As I see code snippet changes doesn’t applyed to your search form.
Looks like you have old plugin version and this snippet just doesn’t works for you.
If you use pro version – please email to wpunitnet@gmail.com for instruction how to get latest plugin version.
Okay that helped. I already had PRO but a old version. Updated to the latest version and now it works. Great!!! Thank you very much for helping me out for so long. Greetings from hamburg germany