wc_get_template filter-hookWC 9.2.0

Filter the order receipt template path.

Usage

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

/**
 * Function for `wc_get_template` filter-hook.
 * 
 * @param string $template      The template path.
 * @param string $template_name The template name.
 * @param array  $args          The available data for the template.
 * @param string $template_path The template path.
 * @param string $default_path  The default template path.
 *
 * @return string
 */
function wp_kama_wc_get_template_filter( $template, $template_name, $args, $template_path, $default_path ){

	// filter...
	return $template;
}
$template(string)
The template path.
$template_name(string)
The template name.
$args(array)
The available data for the template.
$template_path(string)
The template path.
$default_path(string)
The default template path.

Changelog

Since 9.2.0 Introduced.

Where the hook is called

ReceiptRenderingEngine::generate_receipt()
wc_get_template
WC_REST_System_Status_V2_Controller::get_theme_info()
wc_get_template
wc_get_template()
wc_get_template
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/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php 1228
$located = apply_filters( 'wc_get_template', $file, $file, array(), WC()->template_path(), WC()->plugin_path() . '/templates/' );
woocommerce/includes/wc-core-functions.php 313
$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 );