Website Building » WooCommerce » Where Do WooCommerce Hooks Go?

Where Do WooCommerce Hooks Go?

Last updated on January 17, 2023 @ 4:50 pm

We often get asked by beginners where do WooCommerce hooks go? The answer is, in your child theme’s functions.php file.

If you don’t have a child theme, you can create one following the instructions in our article How to Create a Child Theme for WooCommerce.

Once you have a child theme set up, open your child theme’s functions.php file and paste the following code:

<?php
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output-wrapper-end', 10);
?>

This will remove all default styling from WooCommerce so that you can style it yourself.

PRO TIP: The following note is a warning for those considering the article, "Where Do WooCommerce Hooks Go?":

This article contains outdated information about WooCommerce hooks. Hooks have been moved to different locations in newer versions of WooCommerce, so following the advice in this article could result in errors on your site.

If you want to keep some of the default styling and just make small changes, you can Target specific WooCommerce elements using CSS.

Where Do WooCommerce Hooks Go?

WooCommerce hooks go in your child theme's functions.

This will remove all default styling from WooCommerce so that you can style it yourself.

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.