After a day of searching and reading literally everything regarding Sage 9 and WooCommerce, I finally came to the conclusion to just start a thread here as I’ve not really came any closer to getting stuff working.
I followed the steps that are stated here https://github.com/mejta/sage-woocommerce. Installed this composer require roots/sage-woocommerce with composer. And created the folder structure as it should. This is how to folder structure looks /resources/views/woocommerce/. In that folder you can put the WooCommerce files which you want to have overwritten. For now I just put ‘archive-product.blade.php’ and ‘single-product.blade.php’ in there. I got the contents of those files from another repo of a different solution (https://github.com/hambos22/sage-woo/tree/master/resources/views).
The above steps should ensure that every template you place inside the newly created folder structure overwrites the default WooCommerce templates. But it does not work unfortunately. I’m clearly missing something…
I’m not sure what I can do next. All help is appreciated!
Doing it through composer looks like the best way to do it in the future, but for now if you follow the gist you can get working and switching over later should be quite easy as both ways involve minimal work.
Hey @bramvdpluijm1 - did you try using the example views provided by @mejta in roots/sage-woocommerce instead of the ones provided in @hambos22’s repo?
Thanks for the quick response guys! I really appreciate it! And it worked . When I followed the guide that @bdmason shared it did the trick. What I did wrong was: I put the woocommerce folder inside the /resources/views folder before. Now it is situated in /resources.
The library is supposed to, the gist I posted is just a little hack to get from resources to views. I think once the library is doing its thing my hack will become redundent. By following the gist he must have bypassed the library for now.
Install Sage with composer create-project roots/sage your-theme-name and setup as normal
Install and setup WooCommerce if not already present
In your theme folder, run composer require roots/sage-woocommerce
Create the folder resources/views/woocommerce/ in your theme
Copy the example templates from roots/sage-woocommerce into resources/views/woocommerce/
From there you can modify the templates as needed or use them as examples for how to create additional templates.
@mejta, thanks for confirming on your end and for the sample repo. I think a guide is a good idea, but I would start with making the readme in the roots/sage-woocommerce repo basically be the guide (clarifying and expanding the current info as needed). Once that’s done, I think it would make sense to also publish it (or an adapted version of it) to the site so that it’s easier for folks to find it.
I went into an existing project and installed the roots/sage-woocommerce package, removed my resources/woocommerce files, made sure the resources/views/woocommerce blades were in the right place and named correctly, and my website went back to how it was with the resources/woocommerce hack that was there before (I checked it was broken in between).
The package appears to do exactly what it should, good job @mejta
@bramvdpluijm1 perhaps you could try again? In my test I took a website using the hack from my gist, removed it (the resources/woocommerce folder), installed the package, then moved my blades into the new place (from my custom woo/ directory to resources/views/woocommerce) and everything worked as expected. If you run into any problems please post them here as they could help @mejta with his guide.
Thanks for looking into it! I will try to remove the hack from your gist and try to install the package again. Maybe I just made a fuck up yesterday. I’ll keep you guys posted.
@mmirus Allright. I did everything again. Removed the hack that @bdmason suggested yesterday. Installed composer require roots/sage-woocommerce. And I also placed the example templates from roots/sage-woocommerceinside resources/views/woocommerce.
I can see that something is happening, but now I don’t have any styling anymore. The head is empty. Also I get notified that a theme without header.php, sidebar.php, footer.php is outdated. I read in the roots/sage-woocommerce repo that it’s default behaviour but I don’t really get what to do next.
This is what is written there:
By default, you will get an error message that themes without header.php, footer.php and sidebar.php are deprecated. You have to replace single-product.php and archive-product.php templates with your Blade template. You can find those two files in /examples/views folder of this package. The trick is not to use get_header, get_footer or get_sidebar functions, because it’s handled differently with Blade. Instead of that, you can use actions:
In the example templates there’s this: do_action('get_header', 'shop');. As suggested in the text above. Still seeing the notices that a theme without header.php is outdated.
Does your blade template have @extends('layouts.app'), and does layouts/app.blade.php look something like this (notice the do_action('get_header') and the 2 header related partials):
It’s a bit hard to help further without seeing the templates.
Also, my woo templates look nothing like the original woo default ones. They look just like my normal blade page templates - pulling the bits and bobs I need from the normal loop, and from wp & woo helper functions where required.
Yep. My blade templates are exact copies of the example files in the roots/sage-woocommerce repo. So the @extends('layouts.app') is present. layouts/app.blade.php is also similar to yours.
Question: do you still place the normal archive-product.php somewhere? I don’t have that as of now so maybe that’s a problem?
Also: Do I have to do something special after I install composer require roots/sage-woocommerce ? Like re-provision the VM or something?