Loading...

Righto here’s a quick explanation of how I managed to get WooCommerce to work with the Roots Sage 9 framework.

Firstly we need to create a woocommerce folder, I’m assuming we have already setup the Roots Sage 9 package, so navigate into the ‘/resources/‘ folder in the Roots Sage package and create a new directory in there called ‘woocommerce’ using your preferred method of creating folders/directories.

Next up we need a couple of files for our woocommerce templates to utilize. I’ve setup two seperate files, one for the product index pages and a seperate one for the individual product templates. You don’t necessarily have to have two, you can have just one and use the woocommerce actions and hooks to organize the data, or as I have here you can split them into templates as per the usual WordPress conventions.

Anyway lets not worry about that for the moment.
Next up I’ve created the first file, named ‘archive-product.php’ which will be the product index page (or pages). Then I need to add the following code to enable the template via the App controller (if thats he right word):

<?php $template = 'woocommerce';
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
    return apply_filters("sage/template/{$class}/data", $data, $template);
}, []);
echo App\Template($template, $data); ?>

Add this code into each template file you create and you’ll be good to go!

Latest Posts

Portfolio

Contact

Fill in the form below to send us a message. Your details will not be used for promotional purposes or passed on to any third parties.

 

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close