Advanced Ajax Search

7 min read

The Ajax Search feature provides a powerful, real-time product search experience for your WooCommerce store. As customers type in the search box, products matching their query appear instantly—without page reloads. This creates a faster, more engaging shopping experience that helps customers find products quickly.

Key Capabilities

  • Instant Search Results: Products appear as customers type, with no page refresh required
  • Multiple Layout Options: Choose dropdown, full-width, or modal (Pro) display styles
  • Smart Search: Search across product titles, descriptions, SKUs, categories, and more
  • Rich Product Cards: Display images, prices, ratings, stock status, and sale badges
  • Category Filtering: Allow customers to narrow results by product category
  • Recent & Popular Searches: Show helpful suggestions based on search history
  • Search Analytics (Pro): Track what customers are searching for and optimize your store

Getting Started #

Enabling Ajax Search

  1. Go to Swift Commerce → Ajax Search in your WordPress admin
  2. Toggle Enable Ajax Search to turn on the feature
  3. Configure your preferred settings across the available tabs
  4. Click Save to apply your changes

Once enabled, the Ajax Search will automatically replace your theme’s default WooCommerce product search (if enabled in settings).


Adding Ajax Search to Your Site #

There are two main ways to add the Ajax Search widget to your pages:

Method 1: Using the Shortcode

The easiest way to add Ajax Search anywhere on your site is using the shortcode.

Basic Shortcode:

Simply paste this shortcode into any page, post, or widget area where you want the search to appear.

Shortcode with Options:

AttributeDescriptionExample
placeholderCustom placeholder textplaceholder=”Find your product…”
category_filterShow category dropdown filtercategory_filter="true"
layoutResults display style: dropdown, fullwidth, or modallayout=”fullwidth”
max_resultsLimit number of results shownmax_results="5"
classAdd custom CSS class for stylingclass=”my-search-box”

Example Shortcodes:

Use CaseShortcode
Basic search[swift_commerce_search]
With custom placeholder[swift_commerce_search placeholder="What are you looking for?"]
With category filter[swift_commerce_search category_filter="true"]
Full-width results[swift_commerce_search layout="fullwidth"]
Modal overlay (Pro)[swift_commerce_search layout="modal"]
Limited results[swift_commerce_search max_results="5"]
All options combined[swift_commerce_search placeholder="Search..." category_filter="true" layout="dropdown" max_results="10"]

Method 2: Using Elementor Widget (Pro)

If you’re using Elementor page builder, you can drag and drop the Ajax Search widget directly onto your page.

Steps:

  1. Open any page in Elementor editor
  2. Search for “Ajax Product Search” in the widgets panel
  3. Drag the widget to your desired location
  4. Configure settings in the Elementor panel

Elementor Widget Features:

SettingDescription
TemplateChoose from Default, Modern, Classic, or Custom styling
Placeholder TextCustomize the search input placeholder
Results LayoutDropdown, Full Width, or Modal
Category FilterShow/hide category dropdown
Display OptionsToggle images, prices, ratings, stock, etc.
Style ControlsFull control over colors, typography, spacing, and shadows

Available Templates:

  • Default: Clean minimalist design with subtle borders and light shadows
  • Modern: Fully rounded corners, prominent shadows, and bold colors
  • Classic: Traditional squared design with solid borders
  • Custom: Full control over every styling aspect

General Tab #

Configure core search behavior and performance settings.

Search Behavior

SettingDescriptionDefault
Minimum CharactersNumber of characters required before search starts3
Maximum ResultsMaximum products to show in dropdown10
Search DelayMilliseconds to wait after typing before searching300ms

Tips:

  • Lower search delay feels more responsive but increases server load
  • Set minimum characters to 2-3 to balance relevance with usability
  • Limit maximum results to 8-12 for best visual experience

Performance & Caching

SettingDescriptionDefault
Enable Search CacheCache search results for faster repeated searchesOff
Cache DurationHow long to keep results in cache1 hour

Enable caching on high-traffic stores to reduce database queries.


Search Tab #

Configure which product fields are searched and set up filtering options.

Search Fields (Pro)

Select which product data to include when searching:

FieldDescription
Product TitleSearch in product names
Product ContentSearch in full product description
Short DescriptionSearch in product excerpt
SKUSearch by product SKU number
CategoriesInclude category names in search
TagsInclude product tags in search
AttributesSearch in product attributes (color, size, etc.)

Stock Settings

SettingDescriptionDefault
Include Out of StockShow out-of-stock products in resultsOn

Category Exclusions

Exclude specific product categories from appearing in search results. Useful for hiding:

  • Private or internal categories
  • Wholesale-only products
  • Discontinued product categories

Customization Tab #

The Customization tab consolidates all visual settings including templates, display options, colors, and styling.

Templates

Choose how search results are displayed:

TemplateDescription
DropdownResults appear directly below the search input
Full WidthResults span the full page width
Modal (Pro)Results appear in a centered overlay with blur background

Result Columns (Pro)

Display search results in single or double column layout.

Width Control

SettingDescriptionDefault
Full WidthExpand search to fill containerOff
Maximum WidthMaximum width in pixels (when not full width)500px

Product Information (Pro)

Toggle which product details appear in search results:

OptionDescription
Product ImageShow product thumbnail
Product PriceDisplay current price (with sale price if applicable)
Category NameShow product category below title
SKUDisplay product SKU number
Product RatingShow star rating and review count
Stock StatusDisplay in stock / out of stock label
Sale BadgeShow “Sale” badge for discounted products

Description Settings (Pro)

SettingDescriptionDefault
Show DescriptionDisplay a short product excerptOff
Description LengthMaximum characters to display50

Colors

Customize the color scheme to match your brand:

ColorDescriptionDefault
Primary ColorMain accent color (buttons, highlights)#2271b1
Secondary ColorSecondary accent color#135e96
Text ColorMain text color#333333
Background ColorResults container background#ffffff

Input Style

SettingDescriptionDefault
Input HeightHeight of search input field44px
Input Font SizeFont size in the search input14px
Border ColorInput border color#e0e0e0
Border WidthInput border thickness1px
Focus Border ColorBorder color when input is focused#2271b1

Border & Shadow

SettingDescriptionDefault
Border RadiusCorner roundness for input and results8px
Box ShadowShadow style: None, Light, Medium, HeavyLight

Text Labels

Customize the text shown to users:

SettingDescriptionDefault
PlaceholderText shown in empty search field“Search products…”
No ResultsMessage when no products found“No products found”
View AllLink text to see all results“View all results”
SearchingText shown while loading results“Searching…”

Shortcode Tab #

The Shortcode tab provides a convenient shortcode generator and examples.

Shortcode Generator

Build a custom shortcode with your preferred options:

  1. Configure options:
    • Placeholder text
    • Enable/disable category filter
    • Select layout (dropdown, fullwidth, modal)
    • Set maximum results
    • Add custom CSS class
  2. Copy the generated shortcode
  3. Paste into any page, post, or widget

The shortcode inherits your global style settings but can override specific options as needed.


Analytics Tab (Pro) #

Track and analyze customer search behavior to optimize your store.

Overview Metrics

MetricDescription
Total SearchesNumber of searches performed
Unique SearchesNumber of distinct search terms
Searches with ResultsSearches that returned products
Searches without ResultsSearches with no matching products
Click-Through RatePercentage of searches that led to product clicks
Average ResultsAverage number of products shown per search

Top Search Terms

View the most frequently searched terms in your store, including:

  • Search term
  • Number of searches
  • Number of clicks
  • Click-through rate (CTR)

Use this data to:

  • Identify popular products to promote
  • Discover product naming opportunities
  • Improve product titles and descriptions

No-Result Searches

See which searches returned zero results. This helps you:

  • Identify missing products customers want
  • Add synonyms for common alternate spellings
  • Improve product discoverability

Data Actions

ActionDescription
RefreshUpdate analytics data
ExportDownload data as CSV or JSON
ClearDelete all analytics data

Time Period Filter

View analytics for:

  • Last 7 days
  • Last 30 days
  • Last 90 days
  • All time

How Ajax Search Works #

Search Flow

  1. Customer Types: As the customer types in the search box, the search waits for the configured delay
  2. Query Sent: Once minimum characters are reached and delay passes, a search request is sent
  3. Products Found: The server searches enabled fields (title, SKU, description, etc.)
  4. Results Displayed: Matching products appear instantly in the dropdown/modal
  5. Customer Clicks: Customer can click a product to visit its page, or “View All” for full results

Result Display

Each product result can show (based on your settings):

  • Product image thumbnail
  • Product title (linked to product page)
  • Category name
  • Price (with sale price if applicable)
  • Star rating
  • Stock status
  • Sale badge

Category Filter

When enabled, a dropdown appears next to the search input allowing customers to:

  • Search all categories (default)
  • Filter results to a specific category
  • Narrow down results for faster product discovery

Replacing Default Search #

When Replace Default Search is enabled:

  • Your theme’s WooCommerce product search form is automatically replaced
  • The Ajax Search appears wherever your theme displays search
  • No additional shortcodes needed for header/sidebar search

To keep your theme’s search alongside Ajax Search, disable this option and use shortcodes or the Elementor widget for placement.


Best Practices #

For Performance

  1. Enable caching on high-traffic stores
  2. Set minimum characters to 3 to reduce unnecessary searches
  3. Limit search fields to relevant data (title, SKU, excerpt)
  4. Use search delay of 300-400ms for balance of speed and server load

For User Experience

  1. Show product images for visual recognition
  2. Display prices so customers know cost immediately
  3. Include stock status to avoid frustration with unavailable items
  4. Use descriptive placeholder text like “Search for shirts, shoes…”

For Conversion

  1. Enable Sale Badge to highlight discounts
  2. Show ratings to build trust
  3. Use Full Width or Modal layout for prominent search on landing pages
  4. Review Analytics regularly to identify improvement opportunities

Troubleshooting #

Search Not Working

  1. Ensure Ajax Search is enabled in settings
  2. Check that you’ve typed at least the minimum characters
  3. Verify your store has published products
  4. Clear any caching plugins and try again

Results Not Appearing

  1. Check browser console for JavaScript errors
  2. Ensure WooCommerce REST API is not blocked
  3. Verify products aren’t excluded by category settings
  4. Confirm products aren’t out of stock (if excluded)

Styling Issues

  1. If colors don’t apply, check for theme CSS conflicts
  2. Use the Custom CSS option in Customization tab
  3. Add !important to override stubborn theme styles
  4. Use the Elementor widget for more granular control

Feature Comparison #

FeatureFreePro
Instant Ajax Search
Dropdown Layout
Full Width Layout
Replace Default Search
Show Product Image
Show Product Price
Show Stock Status
Color Customization
Shortcode Support
Search Caching
Modal Layout
Search Field Selection
Multi-Column Results
Product Description in Results
Elementor Widget
Search Analytics
Export Analytics Data
Synonym Support
Typo Tolerance
Remove Credits
Updated on December 28, 2025
Scroll to Top