public static function getThemeTemplate($template, $type, $templates)
    {

        if (class_exists('WC_Template_Loader') && !self::$woocommerce_loaded) {
            self::$woocommerce_loaded = true;
            if (is_page_template()) {
                self::$templates[] = get_page_template_slug();
            }
            if (is_singular('product')) {
                $object = get_queried_object();
                $name_decoded = urldecode($object->post_name);
                if ($name_decoded !== $object->post_name) {
                    self::$templates[] = "single-product-{$name_decoded}";
                }
                self::$templates[] = "single-product-{$object->post_name}";
                self::$templates[] = "single-product";
            }
            if (is_product_taxonomy()) {
                $object = get_queried_object();
                self::$templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug;
                self::$templates[] = 'taxonomy-' . $object->taxonomy;
                self::$templates[] = 'archive-product';
            }
            if (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
                self::$templates[] = 'archive-product';
                $default_file = current_theme_supports('woocommerce') ? 'archive-product.php' : '';
            }
            $fixed_woocommerce_folder = array();
            foreach (self::$templates as $item) {
                $fixed_woocommerce_folder[] = 'woocommerce.' . $item;
                $fixed_woocommerce_folder[] = $item;
            }
            self::$templates = $fixed_woocommerce_folder;
        }

        foreach ($templates as $t) {
            self::$templates[] = basename($t, '.php');
            if (substr(basename($t, '.php'), 0, 6) === "single") {
                $type = substr(basename($t, '.php'), 7);
                self::$templates[] = $type . '/single';
            }
            if (substr(basename($t, '.php'), 0, 7) === "archive") {
                $type = substr(basename($t, '.php'), 8);
                self::$templates[] = $type . '/archive';
            }

        }
        return $template;
    }