WC Status: Template Overrides with .blade.php file paths

Hi there,

as the roots forum has too many separated WooCommerce topics, I’m happy that @mtxz started a summary at https://github.com/mtx-z/Sage9-Woocommerce-Integration. I started an issue there but also wanted to crosspost here for reference:

I did a couple of adjustments and I’ll be happy to provide them later. For now I had the issue that I want to set the template version within the custom WC .blade.php files by using at the beginning of each file e.g.:

`{{–
Displays a single product content
@version 3.4.0
–}}´

That will help to solve compatibily issues later when using the WC Status page to see all overrides.
However the current 'wc_get_template'filter returns the path to the .php files in the cache with a filename which isn’t readable. So I’m trying to find a solution to return the blade path instead for that specific scenario. I tried to minimize the extra code to a minimum but it’s quite hard to limit my addition to only that specific request.

This is what I came up so far:

`add_filter( ‘wc_get_template’, function ( $located, $template_name, $args, $template_path, $default_path) {
$bladeTemplate = locate_template( [ $template_name, ‘resources/views/’ . WC()->template_path() . $template_name ] );

// If we're in dashboard on the WC status page and the request comes from class 'WC_REST_System_Status_Controller' and function 'get_theme_info':
// return .blade.php path
if ( is_admin() ) {
    if( strpos(get_current_screen()->id, 'wc-status') ) {
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
        foreach($backtrace as $call) {
            if( (isset($call['class']) && $call['function']) && ($call['class'] == 'WC_REST_System_Status_Controller') && $call['function'] == 'get_theme_info') {
                return $bladeTemplate;
            }
        }
    }
}

if ( $bladeTemplate ) {
    return template_path( $bladeTemplate, $args );
}
return $located;

}, PHP_INT_MAX, 5 );`

Maybe you have a better idea or some input to make this as performant as possible. Until now I’m also not sure whether this could be useful for other WC parts as well.

Best Regards,

Philipp