How to Limit Product Search on WooCommerce Manual Admin Orders

How to Limit Product Search on WooCommerce Manual Admin Orders
On this page
  1. Why the Default Product Search Can Be Slow for Manual Orders
  2. Step 1: Add the Restricted Search Filter
  3. Step 2: Scope It More Precisely (Recommended)
  4. Troubleshooting
  5. Frequently Asked Questions
  6. Conclusion

You can limit product search on WooCommerce manual admin orders by filtering woocommerce_product_pre_search_products to return a fixed array of product IDs instead of searching the entire catalog — speeding up the “Add products” search on large stores where staff only ever add a handful of recurring products.

Why the Default Product Search Can Be Slow for Manual Orders

  • On a store with thousands of products, the “Add items > Add products” search box queries the full catalog on every keystroke
  • If staff only ever add the same handful of products to manual/phone orders, searching the whole catalog is unnecessary overhead
  • Restricting the search pool to a known set of IDs makes the admin search noticeably faster
  • It’s a targeted optimization, not a general-purpose change — only worth doing for stores with this specific manual-order pattern

Step 1: Add the Restricted Search Filter

PHP
/** Limit the manual order product search to a fixed set of product IDs */
add_filter( 'woocommerce_product_pre_search_products', 'restrict_manual_order_product_search', 20, 6 );

function restrict_manual_order_product_search( $custom_query, $term, $type, $include_variations, $all_statuses, $limit ) {
    if ( ! is_admin() ) {
        return $custom_query;
    }

    $frequently_used_ids = array( 21230, 21231, 21245 );

    return $frequently_used_ids;
}

The example above restricts search everywhere in wp-admin, which is likely too broad. Scope it specifically to the order-item search context using a distinguishing request parameter, so product search elsewhere in the admin (like the Products list) isn’t affected.

PHP
/** Only restrict search when adding items to a manual order specifically */
add_filter( 'woocommerce_product_pre_search_products', 'restrict_search_for_order_items_only', 20, 6 );

function restrict_search_for_order_items_only( $custom_query, $term, $type, $include_variations, $all_statuses, $limit ) {
    if ( empty( $_GET['action'] ) || 'woocommerce_json_search_products_and_variations' !== $_GET['action'] ) {
        return $custom_query;
    }

    return array( 21230, 21231, 21245 );
}

Troubleshooting

Search Is Restricted Everywhere, Not Just Order Items

This means the filter wasn’t scoped precisely enough — check that the request-context condition (like matching the specific AJAX action) is actually correct for your WooCommerce version, since the exact action name can vary slightly between versions.

Legitimate Products Are Missing From Search Results

Update the hardcoded ID array as your frequently-used product list changes — this approach requires manual maintenance, so it’s best suited to a genuinely stable, small set of products rather than a catalog that changes often.

Frequently Asked Questions

Is this worth doing for a small catalog?

Not really — the performance benefit is most noticeable on stores with thousands of products where the default search genuinely feels slow; small catalogs won’t see a meaningful difference.

Can different staff members have different restricted product lists?

Yes — add a role or user-ID check inside the filter function to return a different ID array depending on who’s currently logged in.

Does this affect the frontend product search too?

No — this filter is specific to the backend product search used when manually adding items to an order; frontend shop search is entirely separate and unaffected.

Conclusion

Restricting the manual order product search to a known set of IDs is a targeted performance fix for large catalogs where staff only ever add the same handful of products — scope the filter precisely to the order-item search context so it doesn’t accidentally restrict product search elsewhere in the admin. Getting this right is really what limit product search on woocommerce manual admin orders comes down to.

See also How to Search Products by Custom Field in the WooCommerce Admin. Then read How to Search Orders by SKU in the WooCommerce Admin.

Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.

Leave a Reply

Schedule a call