-
-
Notifications
You must be signed in to change notification settings - Fork 56
Issues with custom taxonomy for product category using sage-woocommerce #18
Comments
Thanks for reporting, @TalkAgency. @mejta is this something you're interested in looking into? |
@mmirus hi, sorry for that, but at the moment I'm thoroughly hooked into another project with tight deadline, so in following days I cannot support that. |
@mmirus One curious thing, the function wc_get_template( 'myaccount/dealer-videos.php' ) only is looking inside the woocommerce plugin at the templates folder. The normal action for this folder is basically: "Try to find at the plugin folder, if don't find, then try on the theme one. So what should happen in this case is to try to find at the Sage Woocomerce folder instead. |
Same problem. I've tried creating both of these: In my case I can work around it by using some conditional logic in my archive-product.blade.php file:
but that won't be great in a lot of situations. |
Just in addition to this, a similar problem is occurring with product attribute templates. For example, my products have a 'group' attribute. I'm pretty sure on a standard WordPress installation you could override this like so: But this doesn't seem to have an effect in sage-woocommerce: |
I appear to be running in to this issue too. |
same same; I can report the same misbehaviour: archive-product.blade.php is overriding everything (except non-blade templates in resources as stated above); using @stuartcusackie work-round works but I have a bad feeling ab |
This issue seems to be caused by A more robust workaround could be to hook on the add_filter('woocommerce_template_loader_files', function ($templates, $default_file) {
if (is_tax('YOUR_CUSTOM_PRODUCT_TAX')) {
$templates[] = 'views/taxonomy-YOUR_CUSTOM_PRODUCT_TAX.blade.php';
// or
// $templates[] = 'views/' . WC()->template_path() . 'taxonomy-YOUR_CUSTOM_PRODUCT_TAX.blade.php';
}
if (is_tax('YOUR_OTHER_CUSTOM_PRODUCT_TAX')) {
$templates[] = 'views/taxonomy-YOUR_OTHER_CUSTOM_PRODUCT_TAX.blade.php';
// or
// $templates[] = 'views/' . WC()->template_path() . 'taxonomy-YOUR_OTHER_CUSTOM_PRODUCT_TAX.blade.php';
}
return $templates;
}, 10, 2); Maybe this package could be updated to use this filter by adding the following (NOT TESTED) : // Logic taken from WC_Template_Loader::get_template_loader_files (private method)
// Lines that unnecessary (IMO) are commented out
// but let me know if you find a case where it turns out that they are needed
add_filter('woocommerce_template_loader_files', function ($templates, $default_file) {
// Not sure the following line is necessary for sage-woocommerce
// $templates[] = 'woocommerce.php';
// Not sure the following lines are necessary for sage-woocommerce
// if ( is_page_template() ) {
// $page_template = get_page_template_slug();
//
// if ( $page_template ) {
// $validated_file = validate_file( $page_template );
// if ( 0 === $validated_file ) {
// $templates[] = $page_template;
// } else {
// error_log( "WooCommerce: Unable to validate template path: \"$page_template\". Error Code: $validated_file." );
// }
// }
// }
if (is_singular('product')) {
$object = get_queried_object();
$name_decoded = urldecode($object->post_name);
if ($name_decoded !== $object->post_name) {
$templates[] = "views/single-product-{$name_decoded}.blade.php";
}
$templates[] = "views/single-product-{$object->post_name}.blade.php";
}
if (is_product_taxonomy()) {
$object = get_queried_object();
$templates[] = 'views/taxonomy-' . $object->taxonomy . '-' . $object->slug . '.blade.php';
$templates[] = 'views/' . WC()->template_path() . 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.blade.php';
$templates[] = 'views/taxonomy-' . $object->taxonomy . '.blade.php';
$templates[] = 'views/' . WC()->template_path() . 'taxonomy-' . $object->taxonomy . '.blade.php';
}
// Not sure the following lines are necessary for sage-woocommerce
// $templates[] = $default_file;
// $templates[] = WC()->template_path() . $default_file;
return array_unique($templates);
}, 10, 2); This would require the maintainers of this repo to watch for any changes of logic in the I did not find an easier way since the Hope this'll help ! |
Submit a feature request or bug report
What is the current behavior?
If I create a new product category called "test" and I create a new file under the folder woocoomerce for override this product category archive it doesn't work.
I've created the file taxonomy-product_cat-test.blade.php and it's not loading. I've tried to reproduce with the same steps on a non-sage installation and works perfect. I think the issue is related with the action of template-loader.
What is the expected or desired behavior?
It should allow you create a custom taxonomy file like a normal Wordpress/Wooocommerce installation so you can override templates.
Bug report
Please provide steps to reproduce, including full log output:
Steps to reproduce:
PS: I've tested on a non-sage installation and it worked. So it definitely should be something with the load-template action.
Please describe your local environment:
WordPress version: 4.9
OS: Windows 10
NPM/Node version: 10
Where did the bug happen? Development or remote servers?
Both
The text was updated successfully, but these errors were encountered: