This function is for developers, which use Oxygen and still want to override plugin-files when it reads in their documentation such as
- Create a folder in your theme folder called
search-filter
. - Copy the file
wp-content\plugins\search-filter\templates\results.php
from the templates folder in to the newly created folder in your theme –wp-content\themes\your-theme-name\search-filter\results.php
Where to put such files, if Oxygen is not a theme
and won't uses themes
?
Put the code in the root-file of your custom plugin, like wp-content\plugins\your-custom-plugin\plugin.php
Now you can copy the "child-theme-files" to wp-content\plugins\your-custom-plugin\oxygen-child-theme\<respective-folder>
or change the value in the oxygen_child_theme_dir_name = 'oxygen-child-theme';
variable.
- WordPress 5+
- Oxygen 2+ and Oxygen 3+
and the plugins
- Search & Filter Pro 2+
- Shortcodes Ultimate 5+
- WooCommerce 3+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
My preferred method to make customizations in WooCommerce is using actions and filters. But there could be some situations where it makes sense to duplicate the WooCommerce templates to the active child theme and edit them.
What if you don’t want to or can’t (like when using Oxygen) override from within the theme and instead want to use a custom plugin though?
Here’s how it can be done.
Step 1
Install and activate My Custom Functionality plugin.
Step 2
Using a FTP client or cPanel file manager, navigate to
/wp-content/plugins/my-custom-functionality-master
Create a directory called woocommerce.
Copy the file(s) you want to override from /wp-content/plugins/woocommerce/templates while maintaining the folder structure.
Ex.: To override cart.php, you would copy
/wp-content/plugins/woocommerce/templates/cart/cart.php
to
/wp-content/plugins/my-custom-functionality-master/woocommerce/cart/cart.php
while creating the directories as needed (in this example, “cart”).
Step 3
Add the following in
/wp-content/plugins/my-custom-functionality-master/plugin.php:
Replace cart.php and cart/cart.php in woocommerce/cart/cart.php as needed.
To override multiple files:
Here we are overriding cart.php and form-billing.php.
custom-plugin
-- cart
--- cart.php
-- checkout
--- form-billing.php
What if you want to override a number of files and do not want to specify the file names/paths each time in the code?
Use the following dynamic code instead:
After this, you can override any WooCommerce template simply by copying it to corresponding directory in your custom plugin’s woocommerce directory and editing it.
Credits:
Woocommerce - overriding the template through a plugin:
https://stackoverflow.com/a/43776583/778809
https://pluginrepublic.com/override-woocommerce-template-plugin/