Custom Search Template for Custom Post Types

Question

I know this is asked a million times, and I’ve found the solution. It seems fairly straight forward but it’s not working for some reason. I wonder if it has something to do with the fact that I’m performing the search using this plugin: https://wordpress.org/plugins/search-filter/ but I have my doubts. I was hoping someone had some insight, maybe I’m missing something. For reference here is my code:

function template_chooser($template) { global$wp_query;
$post_type = get_query_var('post_type'); if($wp_query->is_search && $post_type == 'product' ) { return locate_template('archive-products.php'); } else {$args = array_merge( $wp_query->query, array( 'post_type' => 'post' ) ); query_posts($args );
}
return \$template;
}