WooCommerce template files contain the template structure and template tags used by the front end of the shop and by HTML emails. When we open a WooCommerce template file, we find hooks almost everywhere, and most WooCommerce output is generated through those hooks. This approach hides the code details inside the templates and avoids some upgrade-related problems, but it also makes template customization in WooCommerce theme development more troublesome. Changes that could previously be handled by adding or removing some markup often need to be rewritten as PHP functions and attached to the right hooks.
WooCommerce template file directory structure
Each major WooCommerce version makes some changes to its template files. All WooCommerce template files can be found in the /woocommerce/templates/ directory. The following links point to the template files for several different versions:
| Version | Files |
|---|---|
| v2.6.0 | View template files |
| v2.5.0 | View template files |
| v2.4.7 | View template files |
| v2.3.8 | View template files |
| v2.2.3 | View template files |
| v2.1.0 | View template files |
| v2.0.20 | View template files |
| v1.6.6 | View template files |
We can override these files in an “upgrade-safe” way. Simply copy the files from the templates directory into a woocommerce directory inside your theme while keeping the directory structure unchanged. If your current theme does not already contain a woocommerce directory, just create one.
One important thing to note is that if your theme contains a woocommerce.php file, the override method above may not work. woocommerce.php has a higher priority than the template files inside the woocommerce directory and will take over the rendering of all WooCommerce templates.
