WooCommerce Hooks Visual Guide

Every template hook in the order it fires, with the callbacks WooCommerce attaches and their priorities, and the add_action that lands where you asked.

This tool needs JavaScript. The hook list ships with the page: nothing is fetched and WooCommerce does not have to be installed.



			

The hard part of WooCommerce theming is not the code, it is the position. Sixty-odd action hooks fire across the templates people override, in an order the markup does not show, and the difference between appearing above the price and below it is a priority number attached to a callback you cannot see.

This lists every one of them in the order it fires, with what WooCommerce already attaches and at which priority, and writes the add_action that lands where you asked.

How to use

  1. Search, or pick a template. The hooks are in the order they run.
  2. Choose a hook.
  3. Choose whether your code should run before WooCommerce’s own callbacks or after them.
  4. Copy the snippet into your child theme’s functions.php.

Example

Adding a delivery note after everything WooCommerce puts in the product summary:

/**
 * woocommerce_single_product_summary, in templates/content-single-product.php.
 * WooCommerce's last callback here is at 40, so 45 runs after everything it adds.
 */
function my_theme_single_product_summary() {
	echo '<p class="my-theme-note">' . esc_html__( 'Free delivery over £50', 'my-theme' ) . '</p>';
}
add_action( 'woocommerce_single_product_summary', 'my_theme_single_product_summary', 45 );

The same hook, before the title instead, is priority 5 rather than 45. That number is the entire difference, and it is why a guide that lists hook names without priorities is half a guide.

Pitfalls

Priority is position. WooCommerce attaches its own callbacks at 5, 10, 20, 30 and 40 on the busy hooks. A number lower than the one you want to precede, higher than the one you want to follow, and 10 means “wherever the queue happens to put me”.

remove_action has to match exactly. The same hook, the same callback name, the same priority. One wrong number and it silently does nothing, which is the commonest hour lost in WooCommerce theming.

Removing a method rather than a function is different. Callbacks added as array( $object, 'method' ) cannot be removed by name without the same object instance. WooCommerce’s template functions are plain functions, which is why the removals here are simple.

Hooks in a block theme’s checkout are a different world. WooCommerce’s block-based cart and checkout do not run these template hooks at all: they are React blocks with their own extensibility. This guide is for the classic shortcode templates, which most shops still run.

Overriding a template throws away its hooks. Copying content-single-product.php into your theme freezes it at today’s version, hooks included. Using the hook instead means you get WooCommerce’s fixes.

Some hooks fire more than once. Anything inside the product loop runs once per product, so an unconditional echo appears on every card.

Check you are on the right page. woocommerce_before_main_content fires on the shop, the product and the taxonomy archives alike; is_product() and friends are how you narrow it.

Compatibility

The hook list is read out of the WooCommerce plugin itself — version 11.1.2 from WordPress.org — by parsing the do_action() calls in its templates and the @hooked annotations WooCommerce writes above them. Nothing here is from memory, and nothing is fetched at runtime: the data ships with the page, so the guide works without WooCommerce installed and without a request to anybody.

The templates covered are the ones people override: the shop archive, the product card, the single product page and its content, the cart and its totals, the checkout and its review table, the order received page, and the account page.

The snippet writer reads the priorities out of the attached list, so “before” and “after” are calculated from what WooCommerce actually attaches on that hook rather than from a guess. Where nothing is attached it says so and uses 10.

When WooCommerce moves a callback, this data goes stale. The version and the date it was read are printed under the snippet for that reason.

Frequently asked questions

Where do I put the code?
A child theme’s functions.php, or a small site plugin. Not the parent theme, and not a template override.
How do I remove something WooCommerce adds?
remove_action() with the same hook, callback and priority. The guide shows all three for every attached callback, which is the information that is usually missing.
Why does my code not appear?
Nine times out of ten the priority puts it somewhere you did not expect, or the hook is on a template your theme has overridden. Check the theme’s own copy of the template first.
Do these work with the cart and checkout blocks?
No. The block-based cart and checkout do not run the classic template hooks. They have their own extensibility API, and moving to it is a rewrite rather than a port.
Is this every WooCommerce hook?
No: it is the template action hooks in the templates people override. WooCommerce has hundreds more filters and actions across its PHP, and those live in its own documentation.

From the people who built this tool

WP Adminify

The WordPress admin, rebuilt: a dashboard worth looking at, menu and column control, a real file manager and the login page your client sees.

See WP Adminify Free version on WordPress.org

Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.