SearchWP

News

how to search by SKU in WooCommerce

Are you wondering how to search by SKU in WooCommerce?

Searching by SKU makes it easier for your customers to find the product they’re looking for.

In this article, we’ll show you how to make WordPress search for WooCommerce product SKUs in a few steps.

Why Search By SKU in WooCommerce

To begin with, let’s recall what the SKU is and what it is used for.

SKU is an abbreviation for Stock Keeping Unit. This is a unique product identifier that you can set and use to track the movement of your inventory.

But, in the case of WooCommerce, it can also be used to provide more relevant search results.

For example, let’s say your customers know the exact SKU of a product they’re looking for.

Why not let them immediately find it by entering the SKU into the search field?

It’s a great idea, except for one thing. WooCommerce stores products and SKUs as custom post types and custom fields, respectively.

By default, WordPress completely ignores custom post types and fields while searching.

So using the native WordPress search engine, your customers won’t find any products even by their titles, not to mention SKUs.

Thankfully, there is a way to make WordPress consider custom post types and custom fields while performing a search.

Let’s take a look at it.

How to Search By SKU in WooCommerce

The easiest way to make WordPress search by WooCommerce products SKU is to use a plugin like SearchWP.

SearchWP logo

SearchWP is the best WordPress search plugin that helps provide your customers with more relevant search results.

It has seamless WooCommerce integration and allows you to enable search by product SKU in just a few clicks.

Here are some other things you can do with this plugin:

  • Track searches. Would you like to find out what search terms your customers use while searching on your site? SearchWP allows you to do so and get useful insights into your audience’s needs.
  • Make documents and PDF files searchable. Have some documents or PDF files on your site that you’d like to share with your customers? Using SearchWP, you can easily make them searchable.
  • Impact on search results order. Have you ever wanted to change the default search results order? SearchWP allows you to exclude or prioritize specific pages in just a couple of clicks.
  • Display search results in live mode. Looking to take your customers’ user experience to the next level? Add live autocomplete search to your WordPress site with SearchWP.

Now, let’s take a look at how you can make WordPress search by WooCommerce products SKUs using SearchWP.

Step 1: Download and Install SearchWP

The first step is to grab your copy of the SearchWP plugin here.

Once done, go to your SearchWP account dashboard and open the Downloads tab.

go to the downloads tab

Then, click the Download SearchWP button to start downloading.

download the searchwp plugin

Copy your SearchWP license key at the bottom left, as you’ll need it soon to activate the plugin.

copy your SearchWP license key

When the download is finished, the next step is to upload the SearchWP ZIP file to your WordPress site.

Need any help with that? Kindly check out this how to install a WordPress plugin step-by-step tutorial.

Once you get SearchWP installed and activated, click the SearchWP button at the top panel of your WordPress dashboard.

go over to the searchwp settings

Then, navigate to the License tab.

go over to the license tab

Paste your plugin license key to the appropriate field and press Activate to activate your copy of SearchWP.

activate your license

Once the SearchWP license is activated, you can proceed to the next step and install the WooCommerce Integration extension.

Step 2: Install and Activate the WooCommerce Integration Extension

This extension allows you to easily integrate SearchWP with WooCommerce, providing your customers with the best user experience.

You can grab it at the WooCommerce Integration Extension download page.

Once there, press the Download Extension button to begin downloading.

download the woocommerce integration extension

When the download is finished, simply install and activate it the same way as SearchWP.

Step 3: Add Custom Post Types as a Search Source

Once you activate the WooCommerce integration extension, the next step is to add custom post types as a search source.

To do so, go over to the Engines tab.

go over to the engines tab

Here you’ll find the list of search engines you currently have.

list of your search engines

Right now, there is only one, the Default search engine which is used for native WordPress searches.

It means that by customizing its settings, you can control how the search works throughout your entire site.

For example, you can indicate what search sources you want WordPress to consider performing a search, adjust the weight of attribute relevance, and many more.

Apart from that, SearchWP allows you to add multiple search engines with individual settings and link them to different search fields.

Now, to make WordPress search by WooCommerce products SKUs, we first need to add custom posts types as a search source to the Default engine.

To do so, click Sources & Settings at the top right.

click sources and settings

Tick the box next to the Products source and press Done.

select products and press done

After that, there will appear the Products search source. As you can see, now it only indexes the title, content, slug, and excerpt of products.

list of the attributes

To make it index SKUs, we need to add them as an attribute to the Products search source.

Step 4: Add SKUs as an Attribute

To do so, click the Add/Remove Attributes button.

click add remove attributes

Then, type SKU into the Custom Fields field and choose the _sku option from the drop-down menu.

choose the sku attribute

When you’re finished, click Done.

press done to add a new attribute

As you can see, our newly added _sku attribute currently has the lowest relevance weight.

the sku attribute weight is on the min

It means that WordPress will give it the lowest priority when searching. Since we don’t want that to be the case, let’s set its weight to the maximum.

To do so, move the slider next to the _sku attribute all the way right.

set the sku attribute weight to the max

Once done, press the Save Engines button at the top right to save the changes you made.

press save engines

That’s it. Now your site visitors can find products by their SKUs. Let’s test our new WordPress search to make sure everything works fine.

Step 5: Test Your New Search

To do so, press the Visit Site button under your site’s name at the top left of the WordPress dashboard.

press the visit site button

For the purposes of this tutorial, we’ve added the “Blue Hoodie” product that has the “BH7564” SKU.

Let’s see if WordPress can find this product solely by SKU.

To do so, we’ll enter the “BH7564” query into the search field on our test site and press Search.

search for a prodcut sku

As you can see, we’ve successfully found the product by its SKU only.

we found our product

It means that WordPress now indexes that attribute and considers it when performing a search.

So, in this article, you learned how to search by SKU in WooCommerce. If you’re ready to provide your customers with this ability, you can grab your copy of SearchWP here.

Would you like to display a search bar on a WooCommerce shop page? Check out how to add a WooCommerce search form to your shop page tutorial.

Looking for a way to make your customers’ search experience even better? Then how to add a custom WooCommerce search widget guide worth your attention.

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “SearchWP is the booster WP needs. It converts search in what it should be. Great plugin!”

  • “Jonathan, the developer, was very responsive to my questions and even made me some custom code modifications. Wonderful service!”

  • “With SearchWP you can tweak your search results so you can better target the needs of your site visitors. You have the power to expand your search into custom fields, target specific areas of your site such as taxonomies, post types, and on and on.”