YITH WooCommerce Wishlist can't find modified template file

I am using the YITH Wishlist plugin (YITH WooCommerce Wishlist) and want to modify the default HTML structure. According to the plugin documentation, it should be enough to place the wishlist.php template file inside the woocommerce folder of the theme.

However, this template is not loading when using the Sage theme. The plugin uses the following code to determine which template to use:

php

Копировать код

$woocommerce_base = WC()->template_path();

$template_woocommerce_path = $woocommerce_base . $path;
$template_path             = '/' . $path;
$plugin_path               = YITH_WCWL_DIR . 'templates/' . $path;

$located = locate_template(
    array(
        $template_woocommerce_path, // Search in <theme>/woocommerce/.
        $template_path,             // Search in <theme>/.
    )
);

if ( ! $located && file_exists( $plugin_path ) ) {
    return apply_filters( 'yith_wcwl_locate_template', $plugin_path, $path );
}

The $located variable is always empty, regardless of whether I place the templates inside the theme folder or the woocommerce folder.

Your post didn’t provide the full context of the function they use, which is named yith_wcwl_locate_template and apparently is pluggable (at least according to this version found on GH)

Since this plugin allows you to completely override the function, this means that you can define it yourself and decide how you want it to work. This also means that you can properly add Blade support for the plugin.

1 Like