WooCommerce Hooks & Filters
Before writing code
Fetch live docs:
- Fetch
https://developer.wordpress.org/plugins/hooks/ for WordPress Hooks fundamentals
- Web-search
site:developer.woocommerce.com hooks for WooCommerce-specific hooks
- Web-search
woocommerce action filter reference for comprehensive hook listings
How Hooks Work
Actions
Fire at specific points in execution — used for side effects (sending emails, writing logs, rendering HTML):
do_action( 'hook_name', $arg1, $arg2 ) — fires the action
add_action( 'hook_name', 'callback', $priority, $accepted_args ) — registers a listener
remove_action( 'hook_name', 'callback', $priority ) — unregisters a listener
- Lower
$priority = runs earlier (default 10)
Filters
Transform data as it flows through the system — must return a value:
apply_filters( 'filter_name', $value, $arg1, $arg2 ) — applies the filter
add_filter( 'filter_name', 'callback', $priority, $accepted_args ) — registers a filter
- Callback receives
$value as first argument, must return the (possibly modified) value
- Chained: each filter's return value is the next filter's input
Priority
- Default:
10
- Lower numbers run first (1 before 10 before 99)
- Use early priorities (1–5) to modify data before others see it
- Use late priorities (20+) to act on fully-processed data
Key WooCommerce Hooks
Product Hooks
| Hook |
Type |
When |
woocommerce_product_get_price |
Filter |
Price is retrieved |
woocommerce_before_single_product |
Action |
Before product page renders |
woocommerce_after_single_product_summary |
Action |
After product summary |
woocommerce_product_options_general_product_data |
Action |
General tab in product edit |
woocommerce_process_product_meta |
Action |
Product is saved |
Cart Hooks
| Hook |
Type |
When |
woocommerce_before_cart |
Action |
Before cart page |
woocommerce_cart_calculate_fees |
Action |
Calculate cart fees |
woocommerce_before_calculate_totals |
Action |
Before totals calculation |
woocommerce_add_to_cart |
Action |
Item added to cart |
woocommerce_cart_item_price |
Filter |
Cart item price display |
Checkout Hooks
| Hook |
Type |
When |
woocommerce_before_checkout_form |
Action |
Before checkout form |
woocommerce_checkout_fields |
Filter |
Modify checkout fields |
woocommerce_checkout_process |
Action |
Validate checkout |
woocommerce_checkout_order_processed |
Action |
Order created from checkout |
woocommerce_payment_complete |
Action |
Payment completed |
Order Hooks
| Hook |
Type |
When |
woocommerce_order_status_changed |
Action |
Order status transition |
woocommerce_order_status_{from}_to_{to} |
Action |
Specific status transition |
woocommerce_new_order |
Action |
New order created |
woocommerce_thankyou |
Action |
Thank-you page |
Admin Hooks
| Hook |
Type |
When |
woocommerce_admin_order_data_after_order_details |
Action |
After order details in admin |
woocommerce_product_data_tabs |
Filter |
Product data tabs |
woocommerce_product_data_panels |
Action |
Product data panels content |
woocommerce_get_settings_pages |
Filter |
Register settings pages |
Lifecycle Hooks
| Hook |
Type |
When |
woocommerce_init |
Action |
WooCommerce initialized |
woocommerce_loaded |
Action |
WooCommerce classes loaded |
before_woocommerce_init |
Action |
Before WC initializes (declare features here) |
woocommerce_after_register_taxonomy |
Action |
After taxonomies registered |
Hook Patterns
Conditional Hook Registration
Register hooks only when needed:
is_admin() — admin-only hooks
wp_doing_ajax() — AJAX-only hooks
is_checkout(), is_cart() — page-specific hooks
Class-Based Hook Registration
Use class methods as callbacks: add_action( 'hook', [ $this, 'method' ] ) or add_action( 'hook', [ __CLASS__, 'static_method' ] )
Removing WooCommerce Default Behavior
remove_action() / remove_filter() with the exact callback and priority that was used to add it. For class methods on singletons, reference the instance: remove_action( 'hook', [ WC()->structured_data, 'method' ] )
Dynamic Hook Names
WooCommerce uses dynamic hooks based on context:
woocommerce_product_get_{$prop} — getter filter for any product property
woocommerce_order_status_{$status} — status-specific action
woocommerce_widget_{$widget_id}_args — widget-specific filter
Best Practices
- Always specify
$accepted_args when your callback needs more than one argument
- Use late priorities when you need the final value (after other plugins have filtered)
- Prefer
add_filter over directly modifying globals
- Use
has_action() / has_filter() to check if a hook is already registered
- Never call
do_action() / apply_filters() on WooCommerce core hooks from your code (fire your own hooks instead)
- Prefix your custom hook names:
do_action( 'my_extension_after_process', $data )
Fetch the WooCommerce hook reference for current hook names, parameters, and deprecation notices before implementing.
1---2name: woo-hooks-filters3description: Master the WordPress hook system for WooCommerce — actions, filters, hook priorities, WooCommerce-specific hooks, and extensibility patterns. Use when adding functionality via hooks or understanding the WooCommerce execution flow.4allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch5metadata:6 source: https://skillmd.com/skills/orcaqubits/woo-hooks-filters7---89# WooCommerce Hooks & Filters1011## Before writing code1213**Fetch live docs**:141. Fetch `https://developer.wordpress.org/plugins/hooks/` for WordPress Hooks fundamentals152. Web-search `site:developer.woocommerce.com hooks` for WooCommerce-specific hooks163. Web-search `woocommerce action filter reference` for comprehensive hook listings1718## How Hooks Work1920### Actions2122Fire at specific points in execution — used for side effects (sending emails, writing logs, rendering HTML):23- `do_action( 'hook_name', $arg1, $arg2 )` — fires the action24- `add_action( 'hook_name', 'callback', $priority, $accepted_args )` — registers a listener25- `remove_action( 'hook_name', 'callback', $priority )` — unregisters a listener26- Lower `$priority` = runs earlier (default 10)2728### Filters2930Transform data as it flows through the system — must return a value:31- `apply_filters( 'filter_name', $value, $arg1, $arg2 )` — applies the filter32- `add_filter( 'filter_name', 'callback', $priority, $accepted_args )` — registers a filter33- Callback receives `$value` as first argument, must return the (possibly modified) value34- Chained: each filter's return value is the next filter's input3536### Priority3738- Default: `10`39- Lower numbers run first (1 before 10 before 99)40- Use early priorities (1–5) to modify data before others see it41- Use late priorities (20+) to act on fully-processed data4243## Key WooCommerce Hooks4445### Product Hooks4647| Hook | Type | When |48|------|------|------|49| `woocommerce_product_get_price` | Filter | Price is retrieved |50| `woocommerce_before_single_product` | Action | Before product page renders |51| `woocommerce_after_single_product_summary` | Action | After product summary |52| `woocommerce_product_options_general_product_data` | Action | General tab in product edit |53| `woocommerce_process_product_meta` | Action | Product is saved |5455### Cart Hooks5657| Hook | Type | When |58|------|------|------|59| `woocommerce_before_cart` | Action | Before cart page |60| `woocommerce_cart_calculate_fees` | Action | Calculate cart fees |61| `woocommerce_before_calculate_totals` | Action | Before totals calculation |62| `woocommerce_add_to_cart` | Action | Item added to cart |63| `woocommerce_cart_item_price` | Filter | Cart item price display |6465### Checkout Hooks6667| Hook | Type | When |68|------|------|------|69| `woocommerce_before_checkout_form` | Action | Before checkout form |70| `woocommerce_checkout_fields` | Filter | Modify checkout fields |71| `woocommerce_checkout_process` | Action | Validate checkout |72| `woocommerce_checkout_order_processed` | Action | Order created from checkout |73| `woocommerce_payment_complete` | Action | Payment completed |7475### Order Hooks7677| Hook | Type | When |78|------|------|------|79| `woocommerce_order_status_changed` | Action | Order status transition |80| `woocommerce_order_status_{from}_to_{to}` | Action | Specific status transition |81| `woocommerce_new_order` | Action | New order created |82| `woocommerce_thankyou` | Action | Thank-you page |8384### Admin Hooks8586| Hook | Type | When |87|------|------|------|88| `woocommerce_admin_order_data_after_order_details` | Action | After order details in admin |89| `woocommerce_product_data_tabs` | Filter | Product data tabs |90| `woocommerce_product_data_panels` | Action | Product data panels content |91| `woocommerce_get_settings_pages` | Filter | Register settings pages |9293### Lifecycle Hooks9495| Hook | Type | When |96|------|------|------|97| `woocommerce_init` | Action | WooCommerce initialized |98| `woocommerce_loaded` | Action | WooCommerce classes loaded |99| `before_woocommerce_init` | Action | Before WC initializes (declare features here) |100| `woocommerce_after_register_taxonomy` | Action | After taxonomies registered |101102## Hook Patterns103104### Conditional Hook Registration105106Register hooks only when needed:107- `is_admin()` — admin-only hooks108- `wp_doing_ajax()` — AJAX-only hooks109- `is_checkout()`, `is_cart()` — page-specific hooks110111### Class-Based Hook Registration112113Use class methods as callbacks: `add_action( 'hook', [ $this, 'method' ] )` or `add_action( 'hook', [ __CLASS__, 'static_method' ] )`114115### Removing WooCommerce Default Behavior116117`remove_action()` / `remove_filter()` with the exact callback and priority that was used to add it. For class methods on singletons, reference the instance: `remove_action( 'hook', [ WC()->structured_data, 'method' ] )`118119### Dynamic Hook Names120121WooCommerce uses dynamic hooks based on context:122- `woocommerce_product_get_{$prop}` — getter filter for any product property123- `woocommerce_order_status_{$status}` — status-specific action124- `woocommerce_widget_{$widget_id}_args` — widget-specific filter125126## Best Practices127128- Always specify `$accepted_args` when your callback needs more than one argument129- Use late priorities when you need the final value (after other plugins have filtered)130- Prefer `add_filter` over directly modifying globals131- Use `has_action()` / `has_filter()` to check if a hook is already registered132- Never call `do_action()` / `apply_filters()` on WooCommerce core hooks from your code (fire your own hooks instead)133- Prefix your custom hook names: `do_action( 'my_extension_after_process', $data )`134135Fetch the WooCommerce hook reference for current hook names, parameters, and deprecation notices before implementing.