我正在定制Woocommerce Wordpress网站。
在Woocommerce产品类别中(class-wc-product.php
) 这个get_price
函数应用筛选器,如下所示:
function get_price() {
return apply_filters(\'woocommerce_get_price\', $this->price, $this);
}
在我的功能中。php我想添加一个过滤器,如下所示:add_filter(\'woocommerce_get_price\', \'custom_price\');
function custom_price($price, $product) {
...
}
当我调用此函数时,会得到以下PHP警告:Warning: Missing argument 2 for custom_price()
为什么缺少第二个参数?是$this
是否未发送到筛选器调用?