Using WooCommerce with Sage

- 3 comments

Development,Roots,Snippets,WooCommerce,WordPress

A lot has changed in WooCommerce and in Sage since Chris Carr wrote about using WooCommerce with Sage; this post is just a brief update on how to get WooCommerce to play nicely with Sage 8.x.

WooCommerce has a remarkable ability to break after updates. Even if you follow their override best practices you could end up having to update the templates that you’ve overridden, so I like to avoid template overrides unless absolutely necessary (I make ample use of action hooks and filters to reduce overrides). So, to get WooCommerce up and running smoothly and without any major template overrides, here’s what I like to do:

  1. Add add_theme_support('woocommerce'); to the setup function in lib/setup.php
  2. Add remove_all_actions('woocommerce_sidebar'); to the bottom of lib/setup.php
  3. In the theme’s root directory, create header-shop.php and footer-shop.php files and leave them blank

After these additions you should be up and running with WooCommerce and Sage without any errors or duplicate content.


Comments

  1. Is this also valid for Sage 9 (not Sage 8)?

    I get Notices:

    Notice: Theme without header.php is deprecated since version 3.0 with no alternative available. Please include a header.php template in your theme. in /var/www/html/site/trunk/wp-includes/functions.php on line 3136

    Notice: Theme without footer.php is deprecated since version 3.0 with no alternative available. Please include a footer.php template in your theme. in /var/www/html/site/trunk/wp-includes/functions.php on line 3136

    Also see https://github.com/roots/sage/issues/1052 .

Leave a Reply to Michael

Click here to cancel reply.