Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

WooCommerce · Guide

How to Find WooCommerce Hooks (Step by Step)

How to Find WooCommerce Hooks (Step by Step)

Short answer

Search the official WooCommerce hook reference for a keyword like cart or checkout, then open the matching template file to see where the hook fires. Use Query Monitor to confirm which hooks run on a page, and search the plugin source for do_action and apply_filters to catch the rest.

Key takeaways

  • The official WooCommerce code reference lists every core hook with its file and line.
  • Template files show where a hook fires and the priority of existing callbacks.
  • Query Monitor reveals which hooks actually ran on a given page.
  • Searching for do_action and apply_filters finds back-end hooks you never see on screen.
  • Block-based cart and checkout pages skip many classic PHP hooks.
  • Add hook code in a child theme or snippets plugin, never in plugin files.

What is the fastest way to find WooCommerce hooks?

The fastest way is to open the official WooCommerce hook reference, search for the page area you want to change, then confirm the hook in the template file that renders that area.

WooCommerce ships with hundreds of action and filter hooks. They let you add or change store output without editing core plugin files, which would be overwritten on the next update.

You have four reliable ways to find them:

  1. The official hook reference for a searchable list.
  2. The template files inside the WooCommerce plugin folder.
  3. A debugging plugin that shows which hooks fire on a page.
  4. A code search across the plugin source for do_action and apply_filters.

Most people combine two of these. You find a candidate hook in the reference, then check the template to see exactly where it fires and what it passes.

If hooks are new to you, start with our explainer on what a WordPress hook is. It covers the difference between actions and filters in plain terms.

What is the difference between action and filter hooks in WooCommerce?

Action hooks let you run your own code at a set point, while filter hooks let you change a value before WooCommerce uses or prints it.

WooCommerce uses the same hook system as WordPress core. The WordPress Plugin Handbook section on hooks explains it well.

Here is the practical difference:

  • Actions fire at a point in the page. You attach a function with add_action() to print a notice, add a field, or send data somewhere.
  • Filters pass a value through your function. You attach with add_filter(), change the value, and return it.

A simple way to tell them apart in source code is the function that creates them. do_action( 'woocommerce_before_cart' ) is an action. apply_filters( 'woocommerce_product_get_price', $price, $product ) is a filter.

This matters when you search. If you want to add something, look for actions. If you want to change existing text, prices or classes, look for filters.

Hook typeCreated withYou attach withMust return a value?Typical use
Actiondo_action()add_action()NoAdd content, run a task
Filterapply_filters()add_filter()YesChange text, prices, arguments

Step 1: How do you use the official WooCommerce hook reference?

Open the WooCommerce code reference, go to the hooks list, and use your browser's find feature to search for a keyword such as cart, checkout or single_product.

WooCommerce publishes a generated code reference with a full hooks list. Each entry links to the file and line where the hook is declared.

Good search terms to try:

  • woocommerce_before_ and woocommerce_after_ for content placement around sections.
  • woocommerce_checkout_ for checkout fields and processing.
  • woocommerce_cart_ for cart table and totals.
  • woocommerce_email_ for transactional emails.
  • woocommerce_product_get_ for product data filters.

WooCommerce also keeps a guide to adding actions and filters on its developer site. It explains naming rules and good practice for extension code.

The reference tells you a hook exists. It does not always tell you where it appears on screen. That is why the next step matters.

Step 2: How do you find hooks in WooCommerce template files?

Open the templates folder inside the WooCommerce plugin, find the template for the page you want to change, and read the do_action() calls in it.

Every storefront page is built from template files. For example:

  • templates/single-product.php and templates/content-single-product.php for product pages.
  • templates/cart/cart.php for the cart table.
  • templates/checkout/form-checkout.php for the checkout form.
  • templates/emails/ for order emails.

Each template has comments at the top of hook calls. In content-single-product.php, you will see a comment block listing which functions are attached to woocommerce_single_product_summary and at what priority.

Those priorities are useful. The product title, price and add-to-cart button are all attached to the same action at different priorities. If you attach your own function at a priority between two of them, your output lands between them.

You can browse the templates on your server through FTP or a file manager. If you need access first, see how to get FTP access to WordPress.

You can also read them online in the WooCommerce GitHub repository. That is handy when you do not want to touch the live server at all.

Step 3: How can a plugin show which hooks fire on a page?

Install a debugging plugin such as Query Monitor, load the store page, and open its hooks panel to see every action that fired and which functions are attached.

Query Monitor is a free developer tool on WordPress.org. Its Hooks & Actions panel lists the hooks that ran during the request, along with attached callbacks and priorities.

You can filter that list by component, so you can show only WooCommerce hooks. This is much faster than reading every template when you are not sure which one controls a page.

A few tips:

  • Use it on a staging copy, not your live store. Our guide to setting up a staging site walks through that.
  • Look at the order of hooks. It mirrors the order of output on the page.
  • Check the callbacks attached by your theme. Some themes move or remove default WooCommerce hooks.

Other plugins that print hook names visually on the front end exist too. Treat them as temporary tools and remove them when you are done, since they add overhead.

Step 4: How do you search WooCommerce source code for hooks?

Search the WooCommerce plugin folder for do_action( and apply_filters( with a code editor or the command line to list every hook and where it lives.

This is the most complete method because it covers hooks that never appear on the front end. Payment processing, order status changes and REST responses all have hooks you will not see on screen.

From a terminal inside wp-content/plugins/woocommerce, a simple search is:

grep -rn "do_action( 'woocommerce_checkout" .

Swap the text to match what you need. In an editor like VS Code, use the Search panel with the folder open. Our guide on using WordPress in VS Code covers setting that up.

When you find a hook, read the lines around it. Note:

  • The exact hook name.
  • The arguments passed, and how many.
  • Whether it is inside a condition that might stop it firing.

How do you use a WooCommerce hook once you find it?

Attach your function with add_action() or add_filter() in a child theme's functions file or a code snippets plugin, matching the hook name and the number of arguments.

Here is a small action example that adds a line under the add-to-cart button on product pages:

add_action( 'woocommerce_after_add_to_cart_button', function () {
    echo '<p class="ship-note">Free shipping on orders over $50.</p>';
} );

And a filter example that changes the add-to-cart text on single products:

add_filter( 'woocommerce_product_single_add_to_cart_text', function ( $text ) {
    return 'Add to basket';
} );

Where to put the code:

  • A child theme keeps changes safe from parent theme updates. See what a child theme is.
  • A snippets plugin lets you add, enable and disable code from the dashboard.

The add_action() function accepts a priority and an argument count. The add_action reference explains both. If a hook passes three arguments and you need all of them, set the count to 3.

Why can't you find the WooCommerce hook you expected?

The most common reasons are that the page uses blocks instead of classic templates, your theme overrides the template, or the hook belongs to an extension rather than WooCommerce core.

Block-based cart and checkout. Newer stores use the Cart and Checkout blocks. Many classic PHP hooks on those pages do not fire with blocks. WooCommerce documents this in its notes on legacy cart and checkout hooks. You may need block-specific extension points or to switch the page back to the classic shortcode.

Theme template overrides. Themes can copy WooCommerce templates into a woocommerce folder in the theme. If the copy is older or edited, it may be missing hooks. Check your theme folder before assuming a hook is broken.

Extension hooks. Payment gateways, subscriptions and booking plugins add their own hooks. Search inside those plugin folders, not just WooCommerce.

Removed hooks. A theme or plugin may call remove_action() on a default hook. Query Monitor will show you what is still attached.

How do the methods compare?

Use the reference for discovery, templates for placement, a debugging plugin for what really runs, and a code search for full coverage.

MethodBest forShows screen position?Needs file access?
Official hook referenceQuick keyword searchNoNo
Template filesFront-end layout changesYes, with prioritiesYes, or GitHub
Query MonitorSeeing what fired on one pageOrder onlyNo
Code searchBack-end and hidden hooksNoYes

A sensible routine for most tasks:

  1. Search the reference for a keyword.
  2. Open the matching template to confirm position.
  3. Test your snippet on staging with Query Monitor open.
  4. Move the snippet to the live site once it works.

What are good habits when working with WooCommerce hooks?

Keep custom code out of core files, prefix your function names, test on staging, and recheck your hooks after major WooCommerce updates.

A few habits that save trouble later:

  • Never edit plugin files directly. Updates will wipe your changes.
  • Prefix function names so they do not clash with other plugins.
  • Comment your snippets with what they do and which hook they use.
  • Read the changelog before big updates, because hooks can be deprecated.
  • Back up first. Our WordPress backup guide covers the options.

If your snippet throws an error, turn on debugging to see the message. The WordPress debugging documentation explains the constants to set in your config file.

For a broader walkthrough of writing hook code, read our guide to using WordPress hooks, actions and filters.

Frequently asked questions

Where is the official list of WooCommerce hooks?

WooCommerce publishes a generated code reference that includes a full hooks list. Each hook links to the source file and line where it is declared, so you can see its arguments and context. Use your browser's find feature to search the list by keyword.

Why does my checkout hook not work anymore?

Your store probably uses the Checkout block instead of the classic checkout shortcode. Many legacy PHP hooks do not fire on block-based cart and checkout pages. Either use the block extension points WooCommerce documents or switch the page back to the classic checkout shortcode.

Do I need to know PHP to use WooCommerce hooks?

You need basic PHP to write the function you attach to a hook. Simple changes, like adding text or changing a button label, only take a few lines. A code snippets plugin makes it easier to add and switch off code without editing theme files.

Can a theme remove WooCommerce hooks?

Yes. Themes can call remove_action on default hooks or override template files that contain them. If an expected hook seems missing, check the woocommerce folder inside your theme and use a debugging plugin to see which callbacks are still attached.

Is it safe to add hook code on a live store?

It is safer to test on a staging copy first. A typo in hook code can cause a fatal error that takes the store offline. Test on staging, back up the live site, then move the working snippet over.

Sources

  1. WooCommerce code reference: Hooks WooCommerce
  2. How to add actions and filters WooCommerce Developer Docs
  3. Legacy cart and checkout hooks WooCommerce Developer Docs
  4. Hooks WordPress Plugin Handbook
  5. Query Monitor WordPress.org Plugins

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.