Hey @masoninthesis, so this will work… eventually. I made a PR to allow filtering for the woocommerce.php file, and it was accepted, but it doesn’t look like it was part of the 2.6.* releases, but it is part of the 2.7 beta. If you can pull in that beta, that would allow you to use the woocommerce.blade.php file.
Otherwise, you can override the templates with Blade templates.
Installed woocommerce 2.7.0 beta, and it’s fixed!.. Well sort of. PHP errors are gone now. But the shop and products pages don’t seem to be wrapped properly. The head is actually completely empty, so it’s missing all stylesheets.
Might this be related to the fact that when I add sage/woocommerce.php, it overrides woocommerce/woocommerce.php, but sage/templates/woocommerce.blade.php doesn’t have any effect?
Everything else is working.
If anyone wants to save time installing 2.7.0 Beta w/ Composer, you can use my git repo:
git@github.com:masoninthesis/woocommerce.git
And to clarify for any future-comers, here’s the steps required for it to work for me w/ Sage 9:
Create archive-product.php and single-product.php in theme root with <?php woocommerce_content(); ?>
Create woocommerce.php in theme root with WC loop <?php woocommerce_content(); ?>
…you should create 2 files in templates/woocommerce - archive-product.php and single-product.php and add only
<?php echo App\Template('woocommerce'); to them.
Then in templates/woocommerce add woocommerce.blade.php that contains
@extends('layouts.base') @section('content') @php(woocommerce_content()) @endsection
The only thing I did different was to place woocommerce.blade.php file inside theme/template folder instead of theme/template/woocommerce.
Did anyone of you guys figure out how to access variables from the controller in your woocommerce templates?
I posted another topic here Controller and WooCommerce where @kalenjohnson explained that the problem is that the template files are not blade templates, and the controller only works with blade templates.
Hey Guys, I’m trying to do the same with latest Sage 9 release but it doesn’t work with blade templates.
The “normal override” works (woocommerce/archive-product.php) though I have no base layout so it’s not really an option. I did try many solutions (they all date from 2017 in alpha of beta version) to have woocommerce.blade.php, but without success.
Here’s what I tried so far:
The above solution from Eljas
I am bringing this thread back to life as I’ve searched and experimented with nearly every option I’ve discovered in this discourse to be able to override template files with Sage 9 but no luck.
Has anyone found an easy solution to this yet? I don’t exactly want to start over using that fork.
I made a composer package out of the solution I used on some projects I did a while ago. Feel free to test it out. Have not had time to test it out on a fresh Sage 9 project. Not sure I like that the package looks everywhere for templates anymore, but the original idea was that woocommerce templates should work just like other templates, and that I also could put templates in a plugin.
It appears to install perfectly. I haven’t had a lot of time to play with it yet but upon initial installation it appears to duplicate the header of a single-product page and completely removes everything else related to WooCommerce.
Here are a couple files I created as you mentioned in the docs but modifying the files presents no change to the single product pages:
Always speaking too soon…
Once I start putting together my own partials for WooCommerce the pages start coming together.
I was under the assumption that the standard WooCommerce pages would appear as default out of the box until I started overwriting them with my own template overrides.
then it should definitely load the default woocommerce templates, but without the duplicate header that get_header( ‘shop’ ); caused in the default single-product.php
Have you had any luck with comments as reviews for WooCommerce with Sage 9?
I’m able to display this at the top of product pages:
But the area lower on the product page where it displays the 7 reviews displays them as comments and the comment/review form doesn’t give the option to choose a star rating when adding a review. (The stars exist because this is previous site being revamped).
I have all the options turned on in WooCommerce and WP to allow comments and reviews.
I can’t find much info on this. If you have any ideas that would be great.
This is a long shot but depending on how old your copy of Sage is, you could be running into this problem where poorly written plugin styles aren’t enqueued properly.
You could check if your copy of Sage includes these commits.