Skip to content

Commit

Permalink
better way to force woocommerce.blade.php as default woocommerce temp…
Browse files Browse the repository at this point in the history
…late + readme
  • Loading branch information
mtx-z committed Jul 17, 2018
1 parent 42c0ae8 commit 4bbc8b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Check dev branches for latest updates.
- [discourse.roots.io](https://discourse.roots.io/t/woocommerce-blade-sage-9/8449/17)
- [discourse.roots.io](https://discourse.roots.io/t/any-working-example-of-sage-9-latest-sage-9-0-0-beta-4-with-woocommerce-3-1-1/10099/17)
- [github](https://github.com/MarekVrofski/Sage-Woocommerce) (much thanks again to [@MarekVrofski](https://github.com/MarekVrofski/) for his improvements)

- [github sage PR](https://github.com/roots/sage/pull/1923)

## Changelog
- 17/07/2018 - test still in progress
- Sage 9.0.1
Expand Down
8 changes: 4 additions & 4 deletions your-sage-theme/app/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* - wp-content/plugins/woocommerce/includes/class-wc-template-loader.php l68 template_loader() calls ->
* - wp-content/plugins/woocommerce/includes/class-wc-template-loader.php l129 get_template_loader_files() that uses 'woocommerce_template_loader_files' filter
* - but in template_loader() the call to locate_template() fails to find our woo.blade.php... only a /resources/woocommerce.php because of STYLESHEETPATH & TEMPLATEPATH templating variables (wp-includes/default-constants.php l344)
* - our override filter_templates() method will return a correct path for woocommerce.blade.php
*
* Added a comment here: https://github.com/roots/sage/issues/1429
*/
add_filter( 'woocommerce_template_loader_files', function ( $default_file ) {
$default_file[] = 'views/woocommerce.blade.php';
return $default_file;
}, PHP_INT_MAX );
add_filter( 'woocommerce_template_loader_files', function ( $templates, $default_file ) {
return filter_templates(array_merge($templates, array_filter([$default_file, 'woocommerce'])));
}, PHP_INT_MAX, 2 );

/**
* Render page using Blade (and get data from controller from sage/template/{$class}/data filter)
Expand Down

0 comments on commit 4bbc8b8

Please sign in to comment.