Visual guide to WooCommerce single product page hooks, actions and filters

WooCommerce product page hooks featured image

In this article, we take a look at what WooCommerce hooks are. We look at the difference between actions and filters – and how to use both. Plus there’s a visual guide to all the hooks in the WooCommerce single product page template.

There’s a full list of all WooCommerce hooks here. It’s an intimidating list so this article will concentrate on hooks in the single product template file and includes a visual guide so you can see where each action and filter is applied.

In this article, we’ll:

  • Explain what hooks are
  • Provide a visual guide to all the hooks on the WooCommerce single product page template
  • Provide a list of all hooks on the WooCommerce single product page template
  • Explain the difference between actions and filters
  • Show how to use add_action and add_filter to add or modify content on the product page
  • Show how to remove actions and filters
  • Provide real-world examples and code snippets for using many of the product page hooks

Let’s start by taking a look at exactly what hooks are in WooCommerce.

What are WooCommerce hooks?

Hooks are used by WooCommerce plugins and themes to add extra functionality. For instance, in our WooCommerce Product Add-Ons Ultimate plugin we use the woocommerce_before_add_to_cart_button hook to allow the store owner to insert extra options for users to configure the product.

As such, hooks are a unique WordPress way to add, remove or modify content on your site without editing code in any core files. You can write your own code and ‘hook’ into certain points in themes, plugins and core files.

WooCommerce, like WordPress itself, makes significant usage of hooks – meaning that you can make changes to your WooCommerce site without worrying about your code getting overwritten the next time WooCommerce releases an update.

There are two types of hook: actions and filters. These allow you to change content in slightly different ways. We’ll look at the difference between actions and filters below – but first, here’s a visual guide to WooCommerce hooks on the single product page template.

WooCommerce product page hooks – visual guide

The image below shows all the hooks available to use on the WooCommerce single product page template. Actions are in green; filters are in blue.

You can embed it on your own site using the following HTML. See below the image for the easiest way to embed this on your site.

<a href="https://pluginrepublic.com/woocommerce-hooks-actions-filters/"><img width="1672" alt="WooCommerce product page hooks" src="https://pluginrepublic.com/wp-content/uploads/2025/10/woocommerce-single-product-page-template-hooks.jpg"></a>
view raw hooks.txt hosted with ❤ by GitHub

Click the image to enlarge it.

Visual guide to WooCommerce single product page template hooks

Embed this graphic on your own site – just add this simple HTML snippet:

<a href="https://pluginrepublic.com/woocommerce-hooks-actions-filters/"><img width="1672" alt="WooCommerce product page hooks" src="https://pluginrepublic.com/wp-content/uploads/2025/10/woocommerce-single-product-page-template-hooks.jpg"></a>
view raw hooks.txt hosted with ❤ by GitHub

You can copy this snippet then paste it into your own blog post. If you’re using the block editor, just paste it into a ‘Custom HTML’ block.

What is the difference between actions and filters?

Filters allow you to modify content; actions are a trigger point where you can insert additional code. Therefore: any custom code that hooks into a filter must return a value (the data that is being filtered); code that hooks into an action does not need to return a value.

So, for example, if you wanted to change the text on the ‘Add to Cart’ button, you can ‘filter’ it using the default WooCommerce hook woocommerce_product_single_add_to_cart_text. Before the text is printed on the page, the woocommerce_product_single_add_to_cart_text filter passes a value – ‘Add to Cart’ – which you can modify, then return the modified value back to the page to be printed.

WooCommerce 'Add to cart' button text filtered

An ‘action’, on the other hand, is a specific point where you can perform your own code. This code be inserting some additional content on to the page or triggering an event. For instance, you could hook into the woocommerce_single_product_summary action to print some extra content above the product name; or you could execute some additional code when the user adds a product to their cart through the woocommerce_add_to_cart action.

Let’s take a look at some examples of how to use actions and filters in WooCommerce.

Hook syntax

Throughout WooCommerce and WordPress itself, there are multiple points where you can hook into existing code and modify its output or trigger additional code.

Let’s look at how WooCommerce and WordPress add hooks to core code.

Example of do_action

The do_action command creates an action hook. It has one required parameter, the name of the action. As an example, WooCommerce has the woocommerce_single_product_summary action in the product page template file. In the woocommerce/templates/content-single-product.php file, you’ll see:

do_action( 'woocommerce_single_product_summary' );

The do_action command tells other plugins and developers that they can execute code at this point in the template file. We’ll look at how to hook into do_action with your own code below. The visual guide below shows you where this hook appears in the single product template.

Example of apply_filters

The apply_filters command allows you to modify data. It has at least two parameters – the name of the hook and the data that can be modified. You can pass other, optional parameters if you like. As an example, WooCommerce allows you to filter the short description text that appears under the price on the single product page. In woocommerce/templates/single-product/short-description.php you’ll see this line of code:

$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

The $short_description variable is the text specified for this product. Using the woocommerce_short_description filter, you can modify, add to or completely remove this text. We’ll look at how to do this below. The visual guide below shows the location of multiple filters on the product page.

How to create an action hook

If you want to hook into an action, you need to use the add_action command. Anywhere you see do_action, you can hook into it using add_action.

Using our example of the woocommerce_single_product_summary action above, we can create a new function that will insert some code at the point in the template file where the action hook is located (see visual guide below).

add_action( 'woocommerce_single_product_summary', 'plugin_republic_single_product_summary', 5 );
function woocommerce_template_single_title() {
echo 'Our content goes here';
}

This will just add some simple text to the product page:

Content added using woocommerce_single_product_summary hook in WooCommerce

The add_action command has four possible parameters:

add_action( $hook_name, $callback_function, $priority, $args );
view raw add_action.php hosted with ❤ by GitHub
  • $hook_name – this is the name of the action hook, in this case woocommerce_single_product_summary
  • $callback_function – this is the name of our function
  • $priority – this is an optional value that defines the order in which multiple actions are processed
  • $args – this is an integer defining how many parameters are passed to the callback function

How to create a filter

Using filters is similar but it’s necessary to return a value. Anywhere you see the apply_filters command, you can hook into using add_filter.

Using our example of the woocommerce_short_description filter above, we can create a function like this to filter the description and pass the updated value back. This would be really useful if we wanted to add the same extra content to multiple products – without needing to edit every product separately.

add_filter( 'woocommerce_short_description', 'plugin_republic_short_description', 5 );
function plugin_republic_short_description( $short_description ) {
$short_description = sprintf(
'%s<p>Special offer!</p>',
$short_description
);
return $short_description;
}

This will add some extra text to the short description.

Extra content added to short description using woocommerce_short_description hook

The add_filter command has four possible parameters:

add_filter( $hook_name, $callback_function, $priority, $args );
view raw add_filter.php hosted with ❤ by GitHub
  • $hook_name – this is the name of the action hook, in this case woocommerce_short_description
  • $callback_function – this is the name of our function
  • $priority – this is an optional value that defines the order in which multiple actions are processed
  • $args – this is an integer defining how many parameters are passed to the callback function

Note that it will always have at least one parameter passed to the callback function. This parameter is the data that you can modify and pass back.

How to remove an action

Sometimes, themes or plugins might trigger code through an action that you don’t want. So you can use the command remove_action to ensure that a specific callback function doesn’t fire.

For example, if you would like to remove the code that outputs the ratings section just below the product price, you can use this line of code:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );

The parameters are:

  • $hook_name – the name of the hook, in this case woocommerce_single_product_summary
  • $callback_function – the name of the function that you would like to disable
  • $priority – this should match the priority parameter in the original add_action command

How to remove a filter

You can remove filters by using the command remove_filter. For example, if you would like to prevent a function called custom_callback from being applied to the woocommerce_short_description filter, you can do:

remove_filter( 'woocommerce_short_description', 'custom_callback', 10 );

So that is an introduction to WooCommerce hooks and how to use them. Let’s look at the actions and filters on the single product page template.

WooCommerce single product page hooks

This section provides a reference to all the hooks in the WooCommerce single product page template, including a list of all do_action commands and the functions hooked to them by default in WooCommerce.

There’s also a list of filters that are applied to elements on the single product page, along with code snippets for each one.

List of WooCommerce single product page actions

Below is a version of the content-single-product.php template file for WooCommerce, showing the location of all the action hooks plus the functions hooked to them. Unlike the actual template file, this includes the actions that are hooked to each do_action command on the page, making it easier for you to move or remove an action.

<?php
/**
* Hook: woocommerce_before_single_product.
*
* @hooked woocommerce_output_all_notices - 10
* add_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
*/
do_action( 'woocommerce_before_single_product' );
?>
<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
<?php
/**
* Hook: woocommerce_before_single_product_summary.
*
* @hooked woocommerce_show_product_sale_flash - 10
* add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
* @hooked woocommerce_show_product_images - 20
* add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
*/
do_action( 'woocommerce_before_single_product_summary' );
?>
<div class="summary entry-summary">
<?php
/**
* Hook: woocommerce_single_product_summary.
*
* @hooked woocommerce_template_single_title - 5
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
* @hooked woocommerce_template_single_rating - 10
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
* @hooked woocommerce_template_single_price - 10
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
* @hooked woocommerce_template_single_excerpt - 20
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
* @hooked woocommerce_template_single_add_to_cart - 30
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
* add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
* @hooked WC_Structured_Data::generate_product_data() - 60
*/
do_action( 'woocommerce_single_product_summary' );
?>
</div>
<?php
/**
* Hook: woocommerce_after_single_product_summary.
*
* @hooked woocommerce_output_product_data_tabs - 10
* add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
* @hooked woocommerce_upsell_display - 15
* add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
* @hooked woocommerce_output_related_products - 20
* add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
*/
do_action( 'woocommerce_after_single_product_summary' );
?>
</div>
<?php do_action( 'woocommerce_after_single_product' ); ?>

WooCommerce single product page filters and usages

Here is a list of filters on the product page with a description of what they do and some code examples for filtering each one.

Here’s how to edit or add classes for the image gallery wrapper.

Filter: woocommerce_single_product_image_gallery_classes

How to modify the product image thumbnail html

You can filter the HTML for the image thumbnail on the single product page directly.

Filter: woocommerce_single_product_image_thumbnail_html

<?php
/**
* Hook: woocommerce_single_product_image_thumbnail_html.
*/
function plugin_republic_single_product_image_thumbnail_html( $html, $attachment_id ) {
// Modify $html here
return $html;
}
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'plugin_republic_single_product_image_thumbnail_html', 10, 2 );

How to dynamically set the number of product thumbnail columns

You can set the number of columns in the product thumbnails section programmatically using this snippet.

Filter: woocommerce_product_thumbnails_columns

<?php
/**
* Hook: plugin_republic_product_thumbnails_columns.
* Filter the number of columns in the thumbnail gallery.
*/
function plugin_republic_product_thumbnails_columns( $cols ) {
$cols = 3;
return $cols;
}
add_filter( 'woocommerce_product_thumbnails_columns', 'plugin_republic_product_thumbnails_columns' );

How to modify the HTML for the WooCommerce sales flash

You can modify the HTML for the Sale! flash.

Filter: woocommerce_sale_flash

<?php
/**
* Hook: woocommerce_sale_flash.
* Update the HTML for the Sale! flash.
*/
function plugin_republic_sale_flash( $html, $post, $product ) {
// Modify the $html here
return $html;
}
add_filter( 'woocommerce_sale_flash', 'plugin_republic_sale_flash', 10, 3 );

How to filter the WooCommerce product name

WooCommerce uses the standard WordPress filter to modify the page name.

Filter: the_title

<?php
/**
* Hook: the_title.
* Modify the product name.
*/
function plugin_republic_the_title( $product_name, $product_id ) {
// Modify the $product_name here
return $product_name;
}
add_filter( 'the_title', 'plugin_republic_the_title', 10, 2 );
view raw the_title.php hosted with ❤ by GitHub

How to modify the product rating HTML

Update the HTML for the rating that appears directly below the product name.

Filter: woocommerce_product_get_rating_html

<?php
/**
* Hook: woocommerce_product_get_rating_html.
* Modify the HTML for the product rating.
*/
function plugin_republic_product_get_rating_html( $html, $rating, $count ) {
// Modify the $html here
return $html;
}
add_filter( 'woocommerce_product_get_rating_html', 'plugin_republic_product_get_rating_html', 10, 3 );

How to dynamically update the WooCommerce product price

Here’s how to update the HTML for the product price.

Filter: woocommerce_get_price_html

<?php
/**
* Hook: woocommerce_get_price_html.
* Modify the HTML for the product price.
*/
function plugin_republic_get_price_html( $price, $product ) {
// Modify the $price HTML here
return $price;
}
add_filter( 'woocommerce_get_price_html', 'plugin_republic_get_price_html', 10, 2 );

How to dynamically modify the WooCommerce short description

Update the HTML for the product short description.

Filter: woocommerce_short_description

<?php
/**
* Hook: woocommerce_short_description.
* Modify the HTML for the short description.
*/
function plugin_republic_short_description( $short_description ) {
// Modify the $short_description HTML here
return $short_description;
}
add_filter( 'woocommerce_short_description', 'plugin_republic_short_description', 10, 1 );

Filter variation attribute option parameters

Update the parameters for the variation attributes.

Filter: woocommerce_dropdown_variation_attribute_options_args

<?php
/**
* Hook: woocommerce_dropdown_variation_attribute_options_args.
* Modify the parameters for the variation attributes.
*/
function plugin_republic_dropdown_variation_attribute_options_args( $args ) {
// Modify the $args HTML here
return $args;
}
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'plugin_republic_dropdown_variation_attribute_options_args', 10, 1 );

Update the HTML for variation attribute options in WooCommerce

Modify the HTML for the variation options.

Filter: woocommerce_dropdown_variation_attribute_options_html

<?php
/**
* Hook: woocommerce_dropdown_variation_attribute_options_html.
* Modify the HTML for the variation options.
*/
function plugin_republic_dropdown_variation_attribute_options_html( $html, $args ) {
// Modify the $html here
return $html;
}
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'plugin_republic_dropdown_variation_attribute_options_html', 10, 2 );

Modify the HTML for the ‘Clear’ options link.

Filter: woocommerce_reset_variations_link

Dynamically update the WooCommerce stock HTML

Modify the HTML for the stock notice on the product page.

Filter: woocommerce_get_stock_html

<?php
/**
* Hook: woocommerce_get_stock_html.
* Modify the HTML for the stock notice on the product page.
*/
function plugin_republic_get_stock_html( $html, $product ) {
// Modify the $html here
return $html;
}
add_filter( 'woocommerce_get_stock_html', 'plugin_republic_get_stock_html', 10, 2 );

How to dynamically update the text on the ‘Add to cart’ button

Here’s how to programmatically update the text displayed on the product ‘Add to cart’ button in WooCommerce.

Filter: woocommerce_product_single_add_to_cart_text

<?php
/**
* Hook: woocommerce_product_single_add_to_cart_text.
* Modify the text displayed on the 'Add to cart' button.
*/
function plugin_republic_product_single_add_to_cart_text( $text, $product ) {
// Modify the $text here
return $text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'plugin_republic_product_single_add_to_cart_text', 10, 2 );

Change the product upsells heading text

Here’s how to programmatically change the text of the upsells section title.

Filter: woocommerce_product_upsells_products_heading

<?php
/**
* Hook: woocommerce_product_upsells_products_heading.
* Modify the text in the upsells section title.
*/
function plugin_republic_product_upsells_products_heading( $text ) {
// Modify the $text here
return $text;
}
add_filter( 'woocommerce_product_upsells_products_heading', 'plugin_republic_product_upsells_products_heading', 10, 1 );

Here’s how to change the text in the title of the ‘Related products’ section.

Filter: woocommerce_product_related_products_heading

WooCommerce hooks – recap

This article featured a graphic to help you visualize where WooCommerce placed its hooks on the single product template page. The graphic identifies actions and filters – and we discuss the difference. There are multiple code snippets to help you create your own actions and filters and make full use of WooCommerce’s product page hooks.

Any questions, just leave a comment below.

Leave a Reply

Your email address will not be published. All fields are required.