UPDATE:
I have been digging through this and have found that self::has_block_template( 'single-product' ) is returning true even though I am not using a block theme.
file includes/class-wc-template-loader.php line 167.
When I changed this to return false it rendered correctly.
Hi @imconfused4sure,
I did try switching to the theme twentytwentyone and it worked correctly
This basically means there is something that needs to be fixed on your theme. Thus, you’d be best placed to reach out to the theme author for further assistance with this.
If you’re a developer and developed your own theme you can also visit the official WooCommerce Facebook Group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.
When I changed this to return false it rendered correctly.
It seems I missed your update here. If it’s resolved you can close the thread otherwise it will be a good idea to get more inputs from other developers in the channels mentioned above.
Cheers.
-
This reply was modified 4 years ago by
Mirko P..
Yes, I understand that there is something in the theme that needs corrected. I was hoping for some insights into what I need to code to get it to not recognize the .html templates.
I will dig through the function more to see if I can figure out how to get it to return false.
Thanks
I found the proper filter to resolve the issue.
function filter_no_woocommerce_block_templates($has_template)
{
return false;
}
function action_add_filter_no_woocommerce_block_templates()
{
add_filter('woocommerce_has_block_template', 'filter_no_woocommerce_block_templates', 10, 1);
}
add_action('template_include', 'action_add_filter_no_woocommerce_block_templates');
Ignore code above. Use this instead.
function action_remove_block_templates()
{
remove_theme_support('block-templates');
}
add_action('after_setup_theme', 'action_remove_block_templates', 15);
function filter_no_woocommerce_block_templates($has_template)
{
return false;
}
function filter_add_filter_no_woocommerce_block_templates($template)
{
add_filter('woocommerce_has_block_template', 'filter_no_woocommerce_block_templates', 10, 1);
return $template;
}
add_filter('template_include', 'filter_add_filter_no_woocommerce_block_templates',10, 1);
Hi @imconfused4sure!
Glad to hear you found a solution! Thanks for sharing it with everybody 🙂
I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new one.
Cheers!