The following code is to override the Product Details page template, It was working since the last update on WooCommerce. Can anyone help me out on this, thanks in advance.
add_filter('template_include', 'wpautomate_plugin_templates');
function wpautomate_plugin_templates( $template )
{
$plugin_path='';
$reflector = new ReflectionClass('Ze_Single_Product_Layout');
$file_name=plugin_dir_path($reflector->getFileName());
$plugin_path=$file_name;
$post_types = array('product');
$template_id=get_post_meta( get_the_ID(), '_product_layout', true );
if (is_singular('product') && !empty($template_id))
{
//render custom template for single product
$template = $plugin_path . 'template/woo-single-page.php';
}
return $template;
}//end of function
You need to call this filter
add_filter('template_include', 'wpautomate_plugin_templates');
with init action hook
add_action('init','load_custom_template_woo');
function load_custom_template_woo(){
add_filter('template_include', 'wpautomate_plugin_templates');
}
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With