HUSKY - Product Filter for WooCommerce

woof_text_search_ids

允许外部搜索引擎(例如 SearchWP)覆盖文本搜索返回的产品 ID,完全替换默认的 WooCommerce 搜索结果。

参数

$external_ids (null|array) — 默认为 Null;返回一个文章 ID 数组以覆盖内置文本搜索结果

$search_text (string) — 用户输入的原始搜索文本

$options (array) — 搜索选项数组,包括 max_posts、page 和其他配置

源文件

ext/by_text/index.php:854

代码示例

add_filter('woof_text_search_ids', function($ids, $search_text, $options) {
    // Integrate with a custom search engine
    if (function_exists('my_custom_search')) {
        return my_custom_search($search_text, $options);
    }
    return $ids;
}, 10, 3);

使用说明

  • 如果过滤器返回一个数组,该数组将立即作为搜索结果返回。
  • 这是用外部搜索服务替换内置文本搜索的主要集成点。
  • 在传递给默认搜索之前,options 数组中的 'page' 参数未设置。