Skip to content
Advertisement

How to check the value of a WooCommerce filter hook parameter?

In WooCommerce you have many hooks & filters. How can I check what is inside of a filter parameter? For example, I want to unset some shipping rates based on certain conditions. How can I check what is inside my $rates or $package parameter?

JavaScript

Advertisement

Answer

You can first enable WordPress debug log by editing your wp-config.php file adding the following lines to enable debug (if these are already defined, edit the values):

JavaScript

Now you can use error_log() function in your code as follows:

JavaScript

As errors are logged, they should appear in wp-content/debug.log. You can open this file in a text editor. Once you have finished, you can disable debug log.

Related: How to debug in WooCommerce 3

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement