# Latest Sage 9, Blade, and WooCommerce

**URL:** https://discourse.roots.io/t/latest-sage-9-blade-and-woocommerce/9462
**Category:** sage
**Tags:** sage9, blade
**Created:** 2017-04-25T21:06:36Z
**Posts:** 11

## Post 1 by @MWDelaney — 2017-04-25T21:06:36Z

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)](https://discourse.roots.io/t/woocommerce-blade-sage-9/8449/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.

Thanks!

---

## Post 2 by @Eljas — 2017-04-25T21:43:38Z

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 :confused:

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](https://github.com/roots/sage/issues/1807) (the last comment from QWp6t).

---

## Post 3 by @MWDelaney — 2017-04-26T00:01:19Z

Thanks, this helped me think about the problem more clearly. I removed the Woocommerce templates I’d created and started over and made some progress.

I have the following in `resources/views/woocommerce/archive-product.php` and `resources/views/woocommerce/single-product.php`

```
<?php echo App\Template('woocommerce');
```

And when I try to view any shop page, I get a 504 Gateway Time-out error.

So it seems to me like something’s changed since Beta 2. I’ll keep digging but any insight from the team would be great.

EDIT NEVER MIND I’M AN IDIOT:

Here’s what I had in `resources/views/woocommerce.blade.php`

```
@extends('layouts.app')

@section('content')
  @while(have_posts()) @php(the_post())
	@php(woocommerce_content())
  @endwhile
@endsection
```

The keener-eyed among you will notice that I left the `while` loop in there despite every piece of documentation on the subject saying to take it out.

Taking it out fixed the problem.

---

## Post 4 by @mtxz — 2017-08-23T15:27:36Z

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’;  
}

---

## Post 5 by @thommeredith — 2018-07-18T22:00:03Z

Hello, we are trying to do this now with sage 9 and woocommerce 3.4.3, any help is suggested, thanks

---

## Post 6 by @MWDelaney — 2018-07-19T02:28:32Z

What have you tried? What isn’t working?

---

## Post 7 by @thommeredith — 2018-07-19T16:10:36Z

Currently I have this setup:

sage/resources/views/woocommerce.blade.php  
sage/resources/views/single-product.blade.php  
sage/resources/views/archive-product.blade.php

All files have this code inside:

```
@extends('layouts.app')

@section('content') 
  @php(woocommerce_content()) 
@endsection
```

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?

---

## Post 8 by @MWDelaney — 2018-07-20T12:45:54Z

Not to sound like a broken record, but have you tried to customize further templates and run into problems? Are you seeing errors?

The best advice I can give in any situation like this is to try.

---

## Post 9 by @benfavre — 2018-11-11T14:09:00Z

For the love of god. Please post an example theme with overrides this is ridiculous

---

## Post 10 by @MWDelaney — 2018-11-11T14:38:07Z

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](https://github.com/roots/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.

---

## Post 11 by @jonasOST — 2018-11-22T09:47:14Z

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?
