WC_Template_Loader::template_loader( string $template )
Load a template.
Description Description
Handles template usage so that we can use our own templates instead of the theme’s.
Templates are in the ‘templates’ folder. WooCommerce looks for theme overrides in /theme/woocommerce/ by default.
For beginners, it also looks for a woocommerce.php template first. If the user adds this to the theme (containing a woocommerce() inside) this will be used for all WooCommerce templates.
Parameters Parameters
- $template
-
(Required) Template to load.
Return Return
(string)
Source Source
File: includes/class-wc-template-loader.php
public static function template_loader( $template ) {
if ( is_embed() ) {
return $template;
}
$default_file = self::get_template_loader_default_file();
if ( $default_file ) {
/**
* Filter hook to choose which files to find before WooCommerce does it's own logic.
*
* @since 3.0.0
* @var array
*/
$search_files = self::get_template_loader_files( $default_file );
$template = locate_template( $search_files );
if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) {
$template = WC()->plugin_path() . '/templates/' . $default_file;
}
}
return $template;
}