Most widely used WooCommerce Hooks

Most widely used WooCommerce Hooks

 What are hooks?
Hooks in WordPress essentially allow you to modify or add code without changing core files. Hooks are used extensively throughout WordPress and WooCommerce and are very useful to make a customization and in plugin, theme development.

There are two types of hook available:

  • Action Hooks allow you to insert custom code at various points (wherever the hook is run).
  • Filter Hooks allow you to manipulate and return a variable which it passes (for instance a product price)

How to use hooks:

Action: To apply a hook on to an action, create a function in your theme’s functions.php file or you can also create a plugin to write a function and hook it on using the add_action() function, as follows:

add_action( 'wp_head', 'ct_add_meta_to_head' );</pre>

function ct_add_meta_to_head () {

echo '<meta name="description" content="This is customized meta description for the page by WP action hook" />' . "
";

}
<pre>