Sage 9 from Roots is an awesome way to build modern, fast WordPress themes with a great developer experience.
Adding support for Woocommerce to Sage 9 is really easy, using a package from Roots themselves and a couple of simple steps.Contact us for more information.
Add sage-woocommerce from Roots
First up, we need to add a package from Roots that enables Woocommerce template files in the Blade templating engine.
The repo for the package is located at https://github.com/roots/sage-woocommerce, and please check out the install instructions there if anything is unclear. Plus, we’ll need some code from the repo in the next step.
First, change directory into your theme folder;
(Replace the path with your correct path)
Then require the package
That’s the big part of the job done!
If you’re interested in how this actually works under the hood to make Woocommerce & Sage work together, check out
src/woocommerce.php in the repo.
Add the necessary template files
Due to some quirks in the way that blade templates work in Sage 9, it’s necessary to override two Woocommerce template files to get everything to work.
The two files we need are
Create the woocommerce folder in your theme
First, create the folder in which we will place Woocommerce template overrides, within your theme.
Add the two Woocommerce overrides
Finally, download the two template files above and place them within this folder.
You should have
Add woocommerce support to your theme
The last required step to make Woocommerce work with Sage is to add Woocommerce support to your theme.
In the hooked function for
after_setup_theme, add theme support for woocommerce by calling
add_theme_support. (This will usually be near the theme support for Soil).
If you wan to remove the Woocommerce styles
Just add the following filter wherever suits you best (
And you’re done!
Happy building with Woocommerce and Sage 9!