Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › can the search read woocommerce variations?
This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko 6 years, 6 months ago.
- AuthorPosts
- July 5, 2016 at 2:32 pm #9409
Hi, can the search read woocommerce variations? One of the variations this site uses is a part number so for instance:
http://www.lawtontools.co.uk/en/product/insulated-hammers-sledge/
has a variation network rail reference 0039/030046
The customer needs to be able to search for 0039/030046 to find the product. It currently isn’t doing this. I went into the setting and just told it to look at everything and reindexed but no joy.
http://www.lawtontools.co.uk/en/?s=0039%2F030046&post_type=product
Please tell me it can do this or I’ve got a massive job putting all those codes into content or tags or something..
July 6, 2016 at 4:27 pm #9414Hi!
Thanks for the proper description and details, it helped me a lot.
I was actually able to find a solution. By default this should work if the proper custom field is selected. First, I have fixed your configuration as the product variation custom post type and the attribute custom field was not selected: https://i.imgur.com/NdaUBGS.png
This alone should have solved the issue, however there were no results for some reason. I’ve logged in via FTP and did a few tests, which revealed, that the reference number is not actually stored with the backslash character in the database, so instead of “0039/030046” they are stored as “0039030046”. Weird enough, but there is a solution.
I’ve put the following code to the functions.php file in your active theme directory:
This code removes the backslash character before the search phrase is passed. This is the best possible solution I could come up with, and it’s transparent to the user.
Because no plugin files were modified, the solution will work after a plugin update as well.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 6, 2016 at 5:29 pm #9415many thanks your help is much appreciated, I will definitely use your plugin again in the future
July 6, 2016 at 5:59 pm #9416sorry, one more glitch. Same thing really on some products they have two codes the network rail reference and also a part code. Again they will want it to be able to search part code. I added those attributes on and reindexed but they don’t appear in the search.
eg
a search for LT/SB/640/LID
which should find this page http://www.lawtontools.co.uk/en/product/aluminium-storage-boxes/
Am I missing something?
Attachments:
You must be logged in to view attached files.July 7, 2016 at 9:55 am #9423Hi!
Well, the problem was, that those reference numbers were stored with the backslash for some reason.
I’ve modified the code to this:
It should probably work correctly now. This snippet will duplicate the phrase if finds a backslash “/” chacarcter, and use the duplicate keyword without them as well.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 7, 2016 at 10:04 am #9424super thanks, all working now 🙂
July 8, 2016 at 10:11 am #9447You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
The topic ‘can the search read woocommerce variations?’ is closed to new replies.