2026 Executive BenchmarkMid-Market Enterprise Modernization: How leaders across unify Commerce, Odoo ERP & AI in 90 days.
WORDPRESS

How to add Woocommerce in sage theme?

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 packa...

Akshar Group Technologies
Dec 27, 2024
2 min read
Verified Source

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)

code
cd .../my_wordpress_site/wp-content/themes/mytheme
Then require the package
code
composer require roots/sage-woocommerce
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

single-product.blade.php

archive-product.blade.php

Create the woocommerce folder in your theme

First, create the folder in which we will place Woocommerce template overrides, within your theme.
code
mytheme/resources/views/woocommerce
Add the two Woocommerce overrides

Finally, download the two template files above and place them within this folder.

You should have

mytheme/resources/views/woocommerce/single-product.blade.php

mytheme/resources/views/woocommerce/archive-product.blade.php

Add woocommerce support to your theme

The last required step to make Woocommerce work with Sage is to add Woocommerce support to your theme.

Open up mytheme/app/setup.php

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 (app/filters.php)
code
// Disable woocommerce stylesheets
add_filter('woocommerce_enqueue_styles', '__return_empty_array');
And you're done!

Happy building with Woocommerce and Sage 9!
Share this playbook
LET'S BUILD WHAT'S NEXT

What's Holding Your Business Back?

Tell us where you want to go, what's getting in the way, and we'll help you figure out the technology to get there.

No sales pitch. Confidential strategic advisory.