Integration Guides

WooCommerce Integration

Drop SearchX into your WooCommerce store in a few minutes using the official SearchX for WooCommerce plugin.


Overview

The SearchX for WooCommerce plugin is available on the official WordPress.org Plugin Directory and packages everything you need into a single WordPress plugin:

  • Two shortcodes: [searchx_bar] for the search bar and [searchx_page] for the full results page. Drop them into pages, posts, headers, widgets, or page-builder templates.
  • A dedicated settings tab at WooCommerce > Settings > SearchX with every widget option grouped logically, no code editing required.
  • Two ways to send searches: Direct to SearchX (recommended), where the shopper's browser calls SearchX with a public browser key that can only search and only from your website, or Through WordPress, a built-in server-side proxy that keeps every key on your server.
  • Built-in Sales from search: one setting sends your paid orders to SearchX, so the dashboard shows the orders and revenue that came from search. No code to paste.
  • Cookie consent: optionally wait for the shopper's consent before SearchX sets its cookies, automatically with the WP Consent API or with one line of JavaScript from any cookie banner.
  • Automatic Add to Cart that uses WooCommerce's native cart URL, so the cart updates exactly as it would from any other product page.
  • Automatic Wishlist support when YITH WooCommerce Wishlist is active.
  • HPOS + Cart & Checkout Blocks compatibility declared, so WooCommerce won't flag the plugin as incompatible on modern stores.

Requirements

WordPress 6.5+, WooCommerce 8.0+ (installed and active), PHP 7.4+, a SearchX account with your catalog imported from your product XML feed. Live tested with WooCommerce up to 11.3.


Step 1: Install the plugin

The fastest path is straight from the WordPress.org directory:

  1. In WordPress, go to Plugins > Add New.
  2. Search for searchx.
  3. Find SearchX for WooCommerce, click Install Now, then Activate.
SearchX for WooCommerce activated in the WordPress plugins list.

That's it for installation. The plugin doesn't activate any storefront changes yet; it waits for you to fill in your credentials in step 2.

Alternative: upload the zip from your SearchX admin

You can also download the plugin zip directly from your SearchX dashboard: open your application, go to the Details tab, scroll to Integration Instructions, pick the WooCommerce tab, and click Download SearchX for WooCommerce plugin.

Integration Instructions in the SearchX admin: the WooCommerce tab with the plugin download button.

Then upload it in WordPress via Plugins > Add New > Upload Plugin, click Install Now, and Activate.

Uploading the plugin zip from Plugins > Add New > Upload Plugin.

Manual install

If you prefer to install by hand, unzip the file and copy the searchx-for-woocommerce/ folder to wp-content/plugins/ on your server, then activate it from the WordPress Plugins screen.


Step 2: Configure your credentials

Open WooCommerce > Settings > SearchX. The tab is organised into sections that mirror the SearchX dashboard, so fill in only what you need.

WooCommerce > Settings > SearchX: paste your App ID and API key, then save.

Credentials

Paste the App ID and API key from your SearchX dashboard, choose how searches are sent, and add a public browser key for the recommended Direct mode. The API URL defaults to production and rarely needs to change.

FieldWhat to put
App IDYour Application ID from the SearchX dashboard.
API KeyThe full API key for this application, from the Keys tab. It stays on your server: Through WordPress uses it for searches and Send orders uses it for orders.
Search requestsDirect to SearchX (recommended) or Through WordPress. A fresh install starts on Through WordPress, because Direct needs a public browser key.
Public browser keyNeeded for Direct to SearchX. See Create a public browser key below. Never paste the full API key here.
API URLDefaults to the production SearchX API URL. Only change for staging environments.
Default languageInitial language for the widget (e.g. en, el). The plugin still honours per-visitor language detection.

The plugin will not save Direct to SearchX without a public browser key: it shows an error and keeps Through WordPress, so your storefront is never left without search. Updating the plugin never changes the mode you already saved.

Create a public browser key

A public browser key can only run searches, and only from the website address set on your SearchX application, so it is safe in the shopper's browser.

  1. In the SearchX admin, open your application and go to the Keys tab.
  2. Click New key and choose the Public browser search scope.
  3. Confirm with the code SearchX emails you.
  4. Copy the key into Public browser key, set Search requests to Direct to SearchX, and save.

Make sure your application's website address matches the address shoppers use, including www. if your store uses it. Requests from any other address are refused.

After saving you should see the standard WordPress confirmation:

Save confirmation after the SearchX settings are stored.

Sales from search & cookies

Both settings are off by default.

FieldPurpose
Send orders to SearchXSends paid orders to SearchX for the Sales from search card. Needs the full API key above. Orders are sent from your server in the background, so checkout never waits for SearchX, and they carry the order lines and totals only, no customer details.
Cookie consentWait for the shopper's consent before setting SearchX cookies. With the WP Consent API plugin and a compatible cookie banner, SearchX follows the shopper's choice for statistics cookies on its own. With any other banner, call window.searchxSetCookieConsent(true) when the shopper agrees.

With Send orders to SearchX on, the plugin saves the shopper's search session on the order at checkout (classic and block checkout) and sends the order once it is paid: Processing or Completed, and cash on delivery only once Completed. Cancelled and refunded orders are sent again so they drop out. If SearchX is unreachable, the order is tried again later and the attempt is logged under WooCommerce > Status > Logs (source searchx).

Remove the pasted snippet

If you added SearchX's Sales from search code to your theme's functions.php or a custom plugin before, remove it once you turn on Send orders to SearchX. While that code is loaded the plugin leaves orders to it, so no order is sent twice, and shows a notice in the WordPress admin.

Cookie consent works like this:

// ✅ From your cookie banner, once the shopper allows statistics cookies
window.searchxSetCookieConsent(true);

// ✅ If the shopper withdraws consent
window.searchxSetCookieConsent(false);

The function exists from the start of the page, so the banner can call it before the SearchX widget has loaded. Search works either way; without consent an order counts in your total revenue but not in the revenue from search.

Layout & behaviour

FieldPurpose
Roots per shortcodeHow many search bars / search pages can appear on the same page (default 3).
Search page pathThe path the search bar redirects to when a shopper submits a query (default /searchx).
Mobile viewportPixel width at which the widget switches to its mobile layout (default 900px).
Default products per pageInitial number of products per page in the results grid: 12, 24, 36, or 48.
Compact paginationUse the more compact pagination control.
AI SearchNo longer has any effect. Agentic AI Search is switched on in your SearchX dashboard.
Layout & behaviour: roots per shortcode, search page path, viewport, pagination.

Search bar popup

FieldPurpose
Quick Add to CartShow an Add to Cart icon next to each product result inside the search bar popup.
Search iconShow the magnifier glyph next to each Recent / Top searches suggestion.

Product cards

FieldPurpose
BrandShow the brand name on each product card.
SizesShow available sizes on each product card.
ColoursShow colour swatches on each product card.
DescriptionShow the product description on each product card.
Sale priceShow the sale price with the original price struck through (requires sale_price data).
Add to Cart buttonShow the Add to Cart button on each card.
WishlistShow the Add to Wishlist heart on each card (requires YITH WooCommerce Wishlist).
Product cards: choose exactly what appears on each result card.

Filter sidebar

FieldPurpose
Brand facetShow the Brand panel in the filter sidebar.
Category facetShow the Categories panel in the filter sidebar.
Price range filterShow the price range slider + min/max inputs.
On Sale filterShow the On Sale toggle (requires sale_price on indexed products).
Size filterShow the Size panel in the filter sidebar.
Colour filterShow the Colour panel in the filter sidebar.
Filter sidebar: pick which facet panels appear on the results page.

Labels & suggestions

Override the default button text. Leave blank to use the SearchX defaults.

FieldPurpose
Search placeholder textText shown inside the empty search input.
Cart button textLabel for the Add to Cart button on each card.
Wishlist button textLabel for the Add to Wishlist button on each card.

Top searches and suggested links

Top searches and suggested links are managed from the SearchX dashboard, not the plugin. Custom widget CSS and translations are configured per application in the SearchX admin SDK settings and applied automatically. The widget fetches these settings at runtime so updates take effect immediately without any WordPress changes.


Add the search bar shortcode where your current site search lives. Typical locations:

  • Your theme's header (in a header builder, custom HTML widget, or a header template part).
  • A WooCommerce-block-based header pattern.
  • The site-wide widget area used by your theme for navigation.
[searchx_bar]
Adding [searchx_bar] in a header widget area with the theme customizer.

Reload the storefront and the SearchX bar takes the place of your search box:

The SearchX search bar live in the storefront header.

Focusing the bar opens the popup with recent searches, top searches and featured products before the shopper even types:

Recent searches, top searches and featured products in the popup.

You can use the shortcode up to 3 times on the same page out of the box (e.g. desktop header + mobile drawer + secondary location). Each instance gets its own root automatically.


Step 4: Create the search results page

Create or pick the page that will display the full SearchX results page, then drop the page shortcode in:

[searchx_page]
A regular WordPress page containing [searchx_page].

Option A: Use the default path. Create a page at /searchx. The search bar's default Search page path matches, so you're done.

Option B: Use a different path or an existing page. Add the shortcode to that page, copy its URL path, then open WooCommerce > Settings > SearchX, set the Search page path field to that path, and save. The search bar will now redirect there.

Point Search page path at your results page (e.g. /search).

Hide the page title

Most themes show the WordPress page title above the content. For a cleaner search layout, hide the title on the SearchX results page using your theme's per-page settings.

The published results page: product grid, filter sidebar, sort and pagination.

Step 5: Test on the storefront

Run through this quick checklist:

  1. Open the storefront and type a product keyword into the SearchX bar; instant results should appear as you type.
  2. Try a misspelled query (e.g. ipone) to confirm typo tolerance.
  3. Open the full results page and test the category, brand, price, size and colour filters configured for your catalog.
  4. Add a product to the cart straight from the results.
  5. Test on mobile.
Instant results with image, price and quick add-to-cart.
Faceted results page for a query, with highlighted matches.
The mobile search experience.

Open your browser's developer tools and look at the network panel:

  • Direct to SearchX: searches go to admin.searchxengine.ai, carrying your public browser key. Your full API key appears nowhere in the page.
  • Through WordPress: searches go to /wp-json/searchx/v1/proxy on your own site. The browser only sees a placeholder key.

Your catalog and analytics

The plugin renders the search experience; your catalog and insights live in the SearchX admin:

  • Catalog: products are imported from your product XML feed (Google Merchant Center, Facebook or Skroutz format) and re-synced automatically on your schedule (hourly or daily). The plugin never reads the WooCommerce database. See Product Import.
Your imported catalog in the SearchX admin, with unique_id matching WooCommerce product IDs.
  • Analytics: every search feeds the real-time dashboard: total searches, failed-search rate, click-through rate, search-to-cart conversion, top and zero-result terms. See Analytics.
The analytics overview for your WooCommerce application.

Add to Cart and Wishlist behaviour

The plugin wires these for you out of the box, no event handlers required.

Add to Cart

When a shopper clicks Add to Cart from either the popup's quick-add icon or a product card, the plugin navigates the browser to WooCommerce's native add-to-cart URL:

?add-to-cart=PRODUCT_ID&quantity=1

WooCommerce handles the cart mutation through its normal request lifecycle, so the cart count, mini-cart, and any cart hooks fire exactly as if the shopper had clicked Add to Cart on a regular product page.

This requires that the unique_id field on each indexed SearchX product matches the WooCommerce product ID. If you import products from a feed, make sure the feed's product ID matches the WooCommerce ID.

Wishlist

When YITH WooCommerce Wishlist is active, Add to Wishlist clicks are posted to the plugin's REST endpoint (/wp-json/searchx/v1/wishlist/add) which adds the product to the shopper's wishlist using YITH's API. No further setup needed.

If YITH is not active, the click instead dispatches a SearchX:woocommerceAddToWishlist browser event you can listen to for custom wishlist handling. See Event Handling.


Security: Direct mode and the server-side proxy

Whichever mode you choose, your full API key never reaches the shopper's browser.

The browser calls the SearchX API itself with your public browser key. That key can only search, and SearchX refuses it from any website address other than the one set on your application. There is no WordPress hop, so search adds no load to your server and results arrive a little faster.

Through WordPress

A short server-side proxy on your site attaches the full API key to each search. Here's what happens:

  1. The browser sees a placeholder API key (searchx-wordpress-proxy) and the proxy URL (/wp-json/searchx/v1/proxy), never your real key.
  2. Every search request the widget makes goes to the proxy first.
  3. The proxy attaches your real API key on the server side and forwards the request to the SearchX API.
  4. The response comes back the same way.

This means:

  • Your API key is never visible in browser dev tools, page source, or browser extensions.
  • The proxy only forwards a small allowlist of SearchX endpoints, so anything else returns 403 and a leaked placeholder key can't be used as a general-purpose relay.
  • Built-in per-IP and global rate limiting protect your API quota against bursts and distributed traffic spikes.
  • The proxy refuses to forward to anything other than the official SearchX hosts.

You don't need to configure any of this. It's enabled the moment you fill in your credentials and keep Search requests on Through WordPress.

Orders

With Send orders to SearchX on, orders are always sent from your server with the full API key, whichever search mode you use.


Customising via wp-config.php (optional)

If you prefer to keep credentials in code instead of the database, define these constants in wp-config.php:

define('SEARCHX_APP_ID', 'your-app-id');
define('SEARCHX_API_KEY', 'your-api-key');
define('SEARCHX_PUBLIC_KEY', 'your-public-browser-key');
// Optional:
define('SEARCHX_API_PAGE_URL', 'https://admin.searchxengine.ai/api/v1');
define('SEARCHX_DEFAULT_LANGUAGE', 'en');
// On/off settings. When defined, these override the settings tab:
define('SEARCHX_SEND_ORDERS', true);
define('SEARCHX_WAIT_FOR_COOKIE_CONSENT', false);

The plugin resolves credentials and supported defaults in this order: saved settings > wp-config.php constants > built-in defaults. The two on/off constants are the exception: when defined, they win over the settings tab, which shows them as locked. So you can mix and match: store credentials in wp-config.php and let merchants tweak the visual toggles from the WooCommerce settings tab. The SDK bundle loads from the SearchX CDN, and custom widget CSS and translations are managed from the SearchX admin SDK settings.


Troubleshooting

Nothing appears on the storefront

  • Check that the SearchX App ID and API key are saved.
  • In Direct to SearchX, check that the public browser key is saved and that your application's website address matches your store's address exactly (https://, www. or not). The browser console shows 4032 for an address mismatch and 4033 when the application has no website address.
  • Check that the [searchx_bar] shortcode is present on the page, template or widget.
  • Check that your theme renders shortcodes in that location.
  • Check that your SearchX catalog has products imported.

The popup works, but the full results page does not

  • Check that the results page contains [searchx_page].
  • Check that the published page path matches Search page path in the settings.
  • If the page is not at /searchx, update the path in WooCommerce > Settings > SearchX.

Add to cart does not work

  • Check that the SearchX product unique_id values match your WooCommerce product IDs (set this in your XML feed).
  • Check that WooCommerce cart/session behaviour works with the active theme.

Wishlist does not add products

  • Check that YITH WooCommerce Wishlist is installed and active if automatic wishlist support is expected.
  • Without YITH, listen for the SearchX:woocommerceAddToWishlist fallback event in your theme. See Event Handling.

"Direct to SearchX needs a public browser key"

You chose Direct to SearchX without a public browser key, so the plugin kept Through WordPress. Create a public browser key, paste it, and save again.

  • Check that Send orders to SearchX is on and the full API key is saved.
  • Look under WooCommerce > Status > Logs for entries from the searchx source.
  • If the WordPress admin shows a notice about the pasted Sales from search code, remove that code.
  • Only paid orders count: Processing or Completed, and cash on delivery once Completed. See Sales from search for how orders are counted.

No analytics or search results

  • Check that the API key belongs to the same SearchX application as the App ID.
  • Check that the product catalog has been imported successfully.
  • Check that the API URL is still https://admin.searchxengine.ai/api/v1, unless SearchX support told you to use another endpoint.

Uninstalling

Deactivating and deleting the plugin from Plugins > Installed Plugins cleans up every option the plugin writes and any order posts still waiting to be sent. No custom tables, no orphan rows in wp_options. The SearchX session saved on past orders stays with those orders.


Previous
OpenCart