HUSKY - Product Filter for WooCommerce

woof_get_request_data

该插件的 data-gate 函数中使用:index.php -> public function get_request_data()这是插件中第一个获取搜索请求数据的函数

可用于对请求数据进行任何必要操作

 

参数

$data (array) — the request data array

源文件

index.php

代码示例


add_filter('woof_get_request_data', function($data) {
    // Add custom filter parameter programmatically
    if (!isset($data['min_price']) AND isset($_GET['custom_min'])) {
        $data['min_price'] = floatval($_GET['custom_min']);
    }
    if (!isset($data['max_price']) AND isset($_GET['custom_max'])) {
        $data['max_price'] = floatval($_GET['custom_max']);
    }
    return $data;
});

使用说明

  • 将此代码添加到您主题的 functions.php 文件或自定义插件中。
  • 该钩子在筛选过程中应用——更改立即生效。
  • 始终从回调函数返回期望的值类型。