I’m customizing a Woocommerce WordPress site.
In the Woocommerce product class (class-wc-product.php
) the get_price
function applies a filter as follows:
function get_price() {
return apply_filters('woocommerce_get_price', $this->price, $this);
}
In my functions.php I want to add a filter as follows:
add_filter('woocommerce_get_price', 'custom_price');
function custom_price($price, $product) {
...
}
When I call this I get the following PHP warning:
Warning: Missing argument 2 for custom_price()
Why is the second argument missing? Is $this
not sent to the filter call?