Why do Woocommerce templates use hooks rather than get_template_part

Why does Woocommerce use hooks rather than including template parts?

I’m in the process of creating my first Woocommerce theme, and it seems that deactivating the current hooks and then readding them to change the order of a section real overkill. To me, it makes more sense that you just include each of the template parts using get_template_part().

What am I missing / what’s the benefit of doing it their way?!

Solutions Collecting From Web of "Why do Woocommerce templates use hooks rather than get_template_part"

I’m not familiar with Woocommerce, but in short, get_template_part() only look for template parts in parent and child themes, not in plugins.

If you look at the source code, get_template_part() uses locate_template which have the following source code (which is where the actual template part is searched for)

function locate_template($template_names, $load = false, $require_once = true ) {
    $located = '';
    foreach ( (array) $template_names as $template_name ) {
        if ( !$template_name )
            continue;
        if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
            $located = STYLESHEETPATH . '/' . $template_name;
            break;
        } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
            $located = TEMPLATEPATH . '/' . $template_name;
            break;
        }
    }

    if ( $load && '' != $located )
        load_template( $located, $require_once );

    return $located;
}

As you can see, locate_template only look for templates in parent and child themes

That is why you cannot use get_template_part() in a plugin or use it to call template parts into a theme from a plugin.

EDIT from comments from @MarkKaplun

Apart from just the general way in which get_template_part() works in retrieving template parts, Mark has also pointed out a valid point in comments about the use of Woocommerce

I would say it differently – since WC is a plugin it can not have any assumptions about which themes are using it and what parts do they have without limiting its adoption, and WC is meant to work with any theme.

/**
 * @since 1.2.0
 *
 */
function add_action(...) {
    /* ... */
}

.

/**
 * @since 3.0.0
 *
 */
function get_template_part(...) {
    /* ... */
}

WooCommerce was launched in September 2011. However, it wasn’t coded in a day, they must have started a few months earlier.

At the time, WP was just post 3.0 (huge update, btw) and nothing about updating WP, themes or plugins was working as smooth as now.

Besides, add_action() and add_filter() are the foundation behind WP concept. You can be sure they will never become obsolete. It’s the way to go when you code something as large as WooCommerce.

As you probably know, WC provides a templating system.