Change the default WooCommerce template directory in your theme

WooCommerce template files can be easily overridden by copying files to a specific directory in your theme. Learn how to change this to match your own theme file structure.

WooCommerce template files contain the markup and structure of the store frontend and HTML emails. All you need to do to override template files is to make a directory named ‘woocommerce’ within your theme directory, then create the files you wish to override within it while keeping the same file structure. The full list of templates and instructions can be found here.

So far so good, however, if you are like me and like to keep your theme files organised in a specific way, there is a hook that enables you to change were woocommerce looks for the override directory.

The code below changes the default woocommerce template path from yourtheme/woocommerce/ to yourtheme/components/woocoommerce.

 * Changes the Woocommerce template path in your theme
 * Replace 'components/woocommerce/' with your desired directory

add_filter('woocommerce_template_path', function(){
	return 'components/woocommerce/';

Remove WooCommerce template files from a Parent theme

The woocommerce_template_path hook can also come in handy when you need to remove any WooCommerce template overrides present in a parent theme. When the location of the WooCommerce template path is changed in your child theme, the parent theme overrides will be ignored.

Recent Articles