Skip to main content

WooCommerce hooks and filters

WooCommerce provides hundreds of actions (hooks) and filters that allow you to modify and extend its functionality without editing core files. This guide covers the most important hooks and how to use them effectively.

Understanding hooks and filters

Actions (Hooks)

Actions allow you to execute custom code at specific points in WooCommerce’s execution. They don’t return values.

Filters

Filters allow you to modify data before it’s used or displayed. They always return a value.

Product hooks

Product loop hooks

These hooks fire within the product loop on shop and archive pages.
From wc-template-hooks.php:83-85:

Single product page hooks

Customize individual product pages:
From wc-template-hooks.php:39-40:

Product price filters

Product data filters

From wc-term-functions.php:183:

Cart hooks

Cart item hooks

Cart total hooks

Checkout hooks

Checkout fields

Checkout process hooks

Order hooks

Order status changes

Order item hooks

User and customer hooks

User registration

From wc-user-functions.php:117:

Customer created

From wc-user-functions.php:198:

Email hooks

Email content

Template hooks

Shop page hooks

From wc-template-hooks.php:69-70:

Content wrappers

From wc-template-hooks.php:30-31:

Widget hooks

Widget filters

From wc-widget-products.php:177:

Admin hooks

Product admin

Hook naming conventions

WooCommerce follows these naming conventions from the WordPress documentation standards:

Lifecycle hooks

Come in pairs (‘before’ and ‘after’):

Escape hooks

Allow short-circuiting of functions:

Best practices for using hooks

Always use proper hook priorities to ensure your code runs in the correct order.

Priority and accepted arguments

Removing hooks

When removing hooks, make sure to use the exact same priority and function name/reference as when the hook was added.

Conditional execution

Always return filtered values

Finding available hooks

To discover available hooks:
  1. Search the WooCommerce codebase: Look for do_action() and apply_filters() calls
  2. Check template files: Templates in woocommerce/templates/ contain many hooks
  3. Review documentation: See the WooCommerce hook reference
  4. Use developer tools: Browser extensions and plugins can help identify hooks

Example: Finding hooks in template files

From woocommerce/templates/content-product.php:

Common use cases

Add custom product badges

Customize email templates

Add custom order statuses

Next steps

Now that you understand WooCommerce hooks and filters:
  1. Review the WooCommerce template structure
  2. Study extension development best practices
  3. Explore the WooCommerce Code Reference
  4. Read the WordPress Plugin Handbook on hooks
  5. Check out real examples in the WooCommerce codebase

Additional resources