Override WooCommerce Template Within Plugin

You might want to override a WooCommerce core template file in your plugin rather than in the theme directory to future proof theme switching.  WooCommerce searches the following locations in this order until a match is found. Let’s alter this slightly so that it searches out plugin folder in order to override the WooCommerce template.

  • your theme / template path / template name
  • your theme / template name
  • your plugin / woocommerce / template name
  • default path / template name

We can override WooCommerce templates by adding the following function and filter.  This basically duplicates and modifies the behavior of the woocommerce_locate_template() function found within woocommerce-core-functions.php.

Leave a Reply

Your email address will not be published. Required fields are marked *