• Resolved Howdy_McGee

    (@howdy_mcgee)


    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 for archive-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 the front-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 for get_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.

Viewing 1 replies (of 1 total)
  • Thread Starter Howdy_McGee

    (@howdy_mcgee)

    I was on the right track for the most part. WooCommerce does use template overrides described above for themes instead of injecting into the content. As it turns out, WooCommerce has twentyseventeen specific support that was throwing me off:

    class-wc-twenty-seventeen.php
    Line 50: output_content_wrapper()

    That was throwing me off as it made it seem like it wasn’t overriding any of the twentyseventeen theme files but in fact it was just using the same wrapper that theme does.

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin Development – How Does Woo Handle Templates?’ is closed to new replies.