HUSKY - Product Filter for WooCommerce

woof_get_filtered_price_query

自版本 2.2.4/1.2.4 起

此钩子已添加,用于与其他插件兼容。

  • 文件: \classes\helper.php
  • public static function get_filtered_price

参数

$sql (string) — the SQL query used to select prices

源文件

classes/helper.php

代码示例


add_filter('woof_get_filtered_price_query', function($sql) {
    // Modify the price range SQL query
    // For example, to exclude certain product types from price calculation
    global $wpdb;
    $sql .= " AND {$wpdb->posts}.post_type NOT IN ('excluded_type')";
    return $sql;
});

使用说明

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