Customize WooCommerce Product Search Field
The WooCommerce Product Search field can be added via a widget and also via a template tag…
get_product_search_form()
Another option is a filter get_product_search_form() by which you can create your own custom search field including using an icon.
The Original Markup
This will just reproduce the form in it’s original format.
The New Markup
Here a fontawesome magnifying glass is added with the original submit removed
Add some CSS
Floating the icon to the right and a splash of color.
If you are just using the WooCommerce Search Widget – the CSS below will get you started.
For an ecommerce heavy site, you want the search to use the woocommerce layout and product results only, this works great for that issue.
Thanks a lot …
It help me a lot.
how to include custom taxonomy like product tag, product category, product brand in this search form?
Nevermind, I found a plugin solution to what I was trying to do with the search options on the site.
I love this! I’m having one little problem I can’t figure out how to fix. The magnifying glass icon is on the left side of the screen, while I want it on the right side of the screen where the button is. I tried doing some CSS to float the icon to the right, but it didn’t work (probably because I’m very much a CSS amatuer):
i.fa.fa-search {
float: right;
}
You can see the misplaced magnifying glass in the top left corner here:
https://inkerdoo.com/
Any suggestions?
Hello,
Please help, I don’t code that much..
I need the search to go throw the products tags,, any advice?
I use https://woodmart.xtemos.com theme.
Thank you
Thank good share sir, how about we need add own query like search form drop-down menu by category option and brand option?
Like this sample
https://imgur.com/a/LCsN8F3
Thanks!
Where specifically should they placed within the functions.php and style.css files for this to work?
Should they be copied somewhere specifically in functions.php and style.css for this to work?
Not specifically – for the CSS code best at the end of the file so it overrides any similar selectors – for the php it doesn’t matter, just remove the opening php tag.
Thanx a lot. Just did a copy-paste in functions.php and style.css of my child-theme. Great result, after modifying css.
Hi Bert,
Either you include this code in functions.php or create a new file (i.e. my-theme-woocommerce.php) and add the code.
To include this file you could add the following code into your functions.php file;
/**
* Check and see if WooCommerce is installed and activated.
* If true, then we load our file, otherwise we skip it.
**/
if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ), true ) ) {
require_once ‘my-theme-woocommerce.php’;
The latter option is nice and handy when you plan on adding a lot of WooCommerce code. Keeps things organized.
Hope that helps.
in which files / folders do I have to change this?
Nuggets of gold can be found on your site; The digital equivalent of the New South Wales goldrush.
Keep on digging for us, it’s highly appreciated!