Forked from Dilden/custom_plugin_WC_templates.php
Last active
November 22, 2022 11:20
-
-
Save rabinkumarpal/05cdd2ae08e3930065a5d5d45bdbe3a0 to your computer and use it in GitHub Desktop.
Useful snippet for overriding WooCommerce templates in your custom WordPress plugin. Just follow the same directory structure as if you were overriding the templates from a theme.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Override woocommerce templates with the templates in my plugin | |
add_filter( 'woocommerce_locate_template', 'custom_plugin_templates'); | |
function custom_plugin_templates ( $template, $template_name, $template_path ) { | |
$check_dis = str_replace('woocommerce', 'your-plugin-name-goes-here/woocommerce', $template); | |
if(file_exists($check_dis)) { | |
$template = $check_dis; | |
} | |
return $template; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment