Skip to content

Commit

Permalink
Add WooCommerce support
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Jul 9, 2017
1 parent afbaf8f commit a071331
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
add_theme_support('soil-nice-search');
add_theme_support('soil-relative-urls');

/**
* Declare WooCommerce support
*/
add_theme_support('woocommerce');

/**
* Enable plugins to manage the document title
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag
Expand Down
18 changes: 18 additions & 0 deletions app/woocommerce.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App;

/**
* WooCommerce Support
*/
add_filter('woocommerce_template_loader_files', function ($search_files, $default_file) {
return filter_templates(array_merge($search_files, [$default_file, 'woocommerce']));
}, 100, 2);
add_filter('woocommerce_locate_template', function ($template, $template_name, $template_path) {
$theme_template = locate_template("{$template_path}{$template_name}");
return $theme_template ? template_path($theme_template) : $template;
}, 100, 3);
add_filter('wc_get_template_part', function ($template, $slug, $name) {
$theme_template = locate_template(["woocommerce/{$slug}-{$name}", "woocommerce/${name}"]);
return $theme_template ? template_path($theme_template) : $template;
}, 100, 3);
2 changes: 1 addition & 1 deletion resources/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
if (!locate_template($file, true, true)) {
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
}
}, ['helpers', 'setup', 'filters', 'admin']);
}, ['helpers', 'setup', 'filters', 'admin', 'woocommerce']);

/**
* Here's what's happening with these hooks:
Expand Down

0 comments on commit a071331

Please sign in to comment.