Sometimes, there is a need to customize how plugins look at the frontend or add new project-specific functionality. In this case, it would be helpful to have the ability to change the templates of a plugin but don’t lose it in updates.
WooCommece, as the leader in the WordPress ecosystem, made the way the rules of proper behavior how the plugins should handle this.
To override the WooCommerce templates, you need to create a folder called “woocommerce” in the root of your there and put the templates that need to be changed there.
In the same way, you can override our plugins’ templates. We include all our templates via the special class called “FileManager.” FileManager, when it renders templates, firstly check if this template exists in your theme. Then if it didn’t find one, the default would be used.
Steps to override a template:
- Choose a template you want to override. All the templates you can override are always stored in the {plugin_dir}/views/frontend.
- Create a folder at the root of your theme with the same name as the plugin’s folder. For example, for Tiered Pricing for WooCommece, you need to create a folder called ”tier-pricing-table”.
- Copy-paste a file (template) from the plugin into your theme’s folder. Please note that you don’t need to create the “frontend” folder. Consider the “views/frontend” folder as a root.