Hi,
I’m trying to implement WooCommerce with the latest dev-master of Sage 9. I’ve followed the various solutions here (Woocommerce & Blade (Sage 9)) without luck. Is there something new needed now that views are in resources/views?
I’ve tried putting woocommerce.blade.php in resources/views and in resources/views/woocommerce and the template doesn’t seem to load. I get the WooCommerce header.php error no matter what I do.
Hey,
I haven’t tried the latest version yet, but the logic which worked on the beta 2 was that woocommerce will load template (single-product.php or archive-product.php_) from your theme’s folder and then you would echo Sage’s get template function in it.
WooCommerce doesn’t recognize blade files so you would need to hack your way to them by calling echo App\Template('woocommerce'); function inside basic php file (in this case archive-product.php and single-product.php). This should work since the template function is one of the default function in Sage.
There shouldn’t be any problems in theory but as I said haven’t have time to try the new version of Sage yet
There was a mention about new filter in WooCommerce which you could use to get template file but I haven’t got time to figure that out yet. You can try if you can get this working by using that: https://github.com/roots/sage/issues/1807 (the last comment from QWp6t).
My single-product.php in resources/views/woocommerce/ don’t seem to override the woocommerce one… But it works for archive-product.php.
Re-writting the woocommerce file (wp-plugins/) directly works.
any idea ?
Had to tweak template_include filter using (#sad):
if(str_contains($template, ‘single-product.php’)) {
$template = get_stylesheet_directory() . ‘/views/woocommerce/single-product.blade.php’;
}
This seems to be working so far, however I will want to override more of the templates, is there any documentation that you have found that works best?
Hi, welcome to the Roots forum. Support here is supplied on a volunteer basis and is often best solicited with a kind word.
Since this topic was created in 2017 the Roots team has, with generous help from the community, created sage-woocommerce, a composer library add-in for Sage which simplifies WooCommerce integration. Its documentation should have the information you need. If not, please feel free to start a new topic and be sure to detail what you’ve tried, and any relevant code you’ve written.
Hi,
I’m trying to solve this and I think we have to look at the root of the problem, is it really sage9 and blade or just the file structure and file filter functions?
Is the problem that WooCommerce is looking for templates in theme-name/woocommerce but sage9 is storing our blade templates in theme-name/resources/views/woocommerce?