Sage WooCommerce custom taxonomy template

Hello,

I’m using generoi/sage-woocommerce to insert templates into my shop.
I have a custom taxonomy called ‘brand’ in WooCommerce’s post type ‘product’. However, whenever I try to create a template (taxonomy-brand.blade.php) it just ignores it and uses the archive-product.blade.php template instead.

I’ve tried loading the template using a filter, but unfortunately doesn’t do anything:

add_filter('woocommerce_template_loader_files', function ($templates, $default_file) {
    if (is_tax('merk')) {
        $templates[] = 'views/' . WC()->template_path() . 'taxonomy-merk.blade.php';
    }
    return $templates;
}, 10, 2);

Any help would be gladly appreciated!
Thanks, Menno

You should find this interesting:

Hi starsis,

Thank you for your reply, however, I already mentioned in my post that I’m using generoi’s package :wink:

Place the templates in resources/views/woocommerce/ as Blade-PHP files.
Comment out that custom PHP loader code, and just rely on the generoi woocommerce package. Does that work?

Hello, do you know if generoi/sage-woocommerce works on Radicle? Of course I will try myself soon.
Thank you

Radicle is based on Sage, so it should work IMHO.

1 Like

Hi starsis,

That’s how I tried it the first time. I’ve been searching for hours why it’s not working.
Once I put the taxonomy under ‘posts’ it does show me the template (inside /views) but it just wont work when they’re linked to products in the folder views/woocommerce

So it just crossed my mind that your current setup/theme uses the new Gutenberg FSE templates for WooCommerce, and not the classic ones.

See this discussion:

1 Like

I’m not using Gutenberg.

Well, I fixed it by adjusting this loader, forgot to add resources/ infront of /views. Oops…

add_filter('woocommerce_template_loader_files', function ($templates, $default_file) {
    if (is_tax('merk')) {
        $templates[] = 'resources/views/woocommerce/taxonomy-merk.blade.php';
    }
    return $templates;
}, 10, 2);