Plugin Development – How Does Woo Handle Templates?
-
I’m developing a plugin and am curious if anyone could break down or provide a link on how WooCommerce so gracefully handles their templating and overrides. Here’s what I know so far:
– class-wc-query.php :: pre_get_posts hook handles most the big bad stuff assuming woocommerce.php + woocommerce_content() doesn’t exist.
– This hooks up with class-wc-template-loader.php which checks against the current theme then provides paths to the plugin template files.That’s all cool but here’s what’s throwing me off. The hook that the WooCommerce Template_Loader is using is
template_include
which completely switches out template A with a provided template ( woo or theme ) but that is not what happens by default.For example, whenever TwentySeventeen is installed and we’ll set Shop as the front page. It pulls in the themes
front-page.php
as expected but WooCommerce, instead of switching out the template forarchive-product.php
as expected, it injects HTML into the content ( as far as I can tell ) which is what is throwing me off. See, the front page still has thefront-page.php
HTML<main>
wrappers around the WooCommerce HTML.To make this more confusing, as far as I can tell it’s pulling in
archive-product.php
which calls specifically forget_header()
( ‘shop’ template if available ) but there’s not a duplicate header.There’s obviously some crucial piece I’m missing in the templating puzzle and am hoping someone can point me in the right direction or clear up how WooCommerce handles it.
- The topic ‘Plugin Development – How Does Woo Handle Templates?’ is closed to new replies.