Sage-9 + WooCommerce

Decided to have quick peek at and a play around with Sage 9.
There seems to be an issue with WooCommerce and the Wrapper in Sage 9.
On all WooCommerce pages, the main content area is blank and I get the following PHP warning…

Warning include(): Filename cannot be empty wp-content/themes/sage-9/templates/layouts/base.php:17

Any ideas?

I had this same issue this week and the only way I got around it was to copy the wc template files in to the template directory and not have them in a sub directory such as templates/layouts/woocomerce/

This annoyed me a little, but I’ve not had the time to figure out what is needed to organise it how I want … yet.

@emzo, @Ash_Bryant:

Check out this blog post covering best practices integrating WooCommerce with Sage: The steps in that post should solve your PHP warning as it removes the unnecessary get_header(), get_sidebar() and get_footer() calls WooCommerce is making.

Let me know if you have any post-review followup questions as I’ve been using WooCommerce with Sage for some time now and I’m happy to help!

@gnowland Thanks, but this is with regard to Sage 9 specifically - it works differently from earlier versions of Sage. With the current version of Sage 9, it seems that you must have copies of single-product.php and archive-product.php in your theme directory when using WooCommerce.

After @Ash_Bryant replied to my post, I did a bit more digging around. WooCommerce shop/single/category/tag pages all seemed to be broken on Sage 9. It seems there is some kind of clash between Sage 9 and WooCommerce when WooCommerce attempts to locate templates from the WooCommerce plugin folder.

As you’re aware, with WooCommerce you can override their templates by copying them to a woocommerce directory within your theme. However, with Sage 9, you have to copy single-product.php and archive-product.php into your theme, otherwise it doesn’t work. WooCommerce template partials (those included vie wp_get_template()) seem to work fine.

In Sage 9, the single-product.php and archive-product.php can go in the root of your theme folder or inside the templates directory.

Related to this, and for a possible fix, see Single_template filter from plugins.

1 Like

@emzo, glad you got it working! Yes, that post is what helped me when I was testing Sage 9 because step one of that blog post is to create archive-product.php and single-product.php in your theme directory :slight_smile:

Thanks for the link to single_template filter from plugins thread, that makes sense!


You can modify the sage wrapper to look inside the templates (WooCommerce) folder if it cannot be found in the usual templates roots directory.

public function getTemplate() { $template = apply_filters('sage/unwrap_' . $this->slug, $this->template) ?: $this->template; return locate_template($template) ?: locate_template('woocommerce/' . $template); }

@allan.chau Perfect. Thanks

I’m getting this error, however I’m getting only on the product category pages. Archive and singles are fine.

Any ideas? I shouldn’t have to create a taxonomy template?

Ended up putting taxonomy-product_cat.php and taxonomy-product_tag.php into templates folder and above error is resolved.

Each template has the following in it

`<?php get_template_part('partials/page-header'); ?>

<?php woocommerce_content(); ?>`

Wondering if I should have to create the taxonomy templates or not. In past setup I didn’t have to.

Yes, I had to put a taxonomy-product_cat.php and taxonomy-product_tag.php into my theme to avoid these errors (as well as single-product.php and archive-product.php).

This wasn’t the case with previous versions of Sage - seems to be a regression with Sage 9. The template wrapper code has changed quite a bit in Sage 9.

I’ve opened an issue on Github.

Big :heart: to @QWp6t for fixing this on the sage-9 branch.
Templates pulled from plugins work as expected now.