Greetings,
The ‘postmeta’ table is where all the custom field data is stored in the database. By default, the WordPress search functionality is set to search the ‘posts’ table only. In order to include the custom fields data in our search, we need to perform a left join on the ‘posts’ and ‘postmeta’ tables in the database and modify the WordPress search query to include custom fields. Finally, we need to add the DISTINCT keyword to the SQL query in order to prevent returning duplicates.
Paste the following into your WordPress child theme’s functions.php. Remove the starting ‘<?php’ if you have other code already active in that file. https://gist.github.com/Artiosmedia/4b0d065bc033885d2b44bbefcdfb6f17
Once installed, cache purged and browser reloaded, try to search a unique Product Code entered from the WordPress default search.