Replace WooCommerce Search results with Datafeedr API search results

In this article we cover how to replace the product search results returned by the WooCommerce search form with results from the Datafeedr API.

For example, when a visitor to your site types in a search query into the WooCommerce search form (usually appearing in your sidebar via the WooCommerce Product Search widget), the user will be redirected to a new page which contains search results for their query coming from the Datafeedr API instead of the subset of your products in your WooCommerce store.

This is a great way to refer sales for products that aren't even in your store!


This method will allow your site's visitors to query the Datafeedr API directly and as often as they want. This could potentially max our your Datafeedr API request limit much quicker than expected. Additionally, if your search page becomes indexed in the search engines, the Datafeedr API could also be queried many times.


Here's how to get started:


Create New "Product Search" Page

Go here WordPress Admin Area > Pages > Add New and create a new page. I created a page named "Product Search" but you can name it whatever you would like. After you have created the page, get the Page ID.


Create a custom plugin

If you haven't done so already, create a custom plugin.


Add custom code

Add the following code to your custom plugin file.


Update page ID

On line #15 of the above code, change 123 to the ID of the new Page you created. Save your changes.

Now when a user types in a search into the WooCommerce Product Search Form, they will be redirected to your new search page and they will see results from the Datafeedr API instead of from your WooCommerce store.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us