WC_Template_Loader::get_template_loader_default_file
Get the default filename for a template except if a block template with the same name exists.
Method of the class: WC_Template_Loader{}
No Hooks.
Returns
String.
Usage
$result = WC_Template_Loader::get_template_loader_default_file();
Changelog
| Since 3.0.0 | Introduced. |
| Since 5.5.0 | If a block template with the same name exists, return an empty string. |
| Since 6.3.0 | It checks custom product taxonomies |
WC_Template_Loader::get_template_loader_default_file() WC Template Loader::get template loader default file code WC 10.6.2
private static function get_template_loader_default_file() {
if (
is_singular( 'product' ) &&
! self::has_block_template( 'single-product' )
) {
$default_file = 'single-product.php';
} elseif ( is_product_taxonomy() ) {
$object = get_queried_object();
if ( self::taxonomy_has_block_template( $object ) ) {
$default_file = '';
} elseif ( taxonomy_is_product_attribute( $object->taxonomy ) ) {
$default_file = 'taxonomy-product-attribute.php';
} elseif ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
$default_file = 'taxonomy-' . $object->taxonomy . '.php';
} elseif ( ! self::has_block_template( 'archive-product' ) ) {
$default_file = 'archive-product.php';
} else {
$default_file = '';
}
} elseif (
( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) &&
! self::has_block_template( 'archive-product' )
) {
$default_file = self::$theme_support ? 'archive-product.php' : '';
} else {
$default_file = '';
}
return $default_file;
}