Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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