wc_get_template filter-hookWC 2.1.0

Allow 3rd party plugins to filter the template file location.

Usage

add_filter( 'wc_get_template', 'wp_kama_wc_get_template_filter', 10, 5 );

/**
 * Function for `wc_get_template` filter-hook.
 * 
 * @param string $located       The located template path.
 * @param string $file          The template file name.
 * @param array  $args          Template arguments.
 * @param string $template_path The template path.
 * @param string $default_path  The default path.
 *
 * @return string
 */
function wp_kama_wc_get_template_filter( $located, $file, $args, $template_path, $default_path ){

	// filter...
	return $located;
}
$located(string)
The located template path.
$file(string)
The template file name.
$args(array)
Template arguments.
$template_path(string)
The template path.
$default_path(string)
The default path.

Changelog

Since 2.1.0 Introduced.

Where the hook is called

WC_REST_System_Status_V2_Controller::get_theme_info()
wc_get_template
ReceiptRenderingEngine::generate_receipt()
wc_get_template
wc_get_template()
wc_get_template
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php 1374
$located = apply_filters( 'wc_get_template', $located, $file, array(), WC()->template_path(), $wc_templates_dir );
woocommerce/src/Internal/ReceiptRendering/ReceiptRenderingEngine.php 214-221
$template_path = apply_filters(
	'wc_get_template',
	$default_template_path,
	'ReceiptRendering/order-receipt.php',
	$data,
	$default_template_path,
	$default_template_path
);
woocommerce/includes/wc-core-functions.php 318
$filter_template = apply_filters( 'wc_get_template', $template, $template_name, $args, $template_path, $default_path );

Where the hook is used in WooCommerce

woocommerce/src/Blocks/Domain/Services/Notices.php 55
add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );