New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add woocommerce_widget_layered_nav_term_anchor_text filter #40734
Conversation
Allow developers to change the anchor text of active filters. Often, one would add the taxonomy (`Brand: Adidas`).
Hi , Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @moory-se , thanks for the PR! I left some code suggestions that will make sure our code linter is happy and also to make a minor security improvement.
plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php
Outdated
Show resolved
Hide resolved
plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php
Outdated
Show resolved
Hide resolved
…av-filters.php Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
…av-filters.php Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
@moory-se Could you please update the PR description to include step-by-step instructions on how to test this? Here are some pointers on testing instructions: https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions |
Hi, I don't think this can be tested really? I added some testing instructions, but they are not very helpful I think. You might think different though, which would be great :) |
@moory-se Ah, I figured out why I was having trouble testing this. There is a block version of this widget now (which the filter you're adding won't affect) and so the old legacy version of the widget gets hidden. So I think if your site is already using the legacy version of the widget, you don't get automatically switched to the block version, but you can't add new instances of the old legacy version. Have you tried the block version of the Active Filters widget? It looks like it actually adds a label telling you which attribute a term is for, which might solve your use case. |
Hi, The block version is not a viable option for us. We have ~850 filters that are conditionally shown on the site. Handling those numbers with the block version would be impractical. This PR is for the widget version, which is not deprecated. The PR also has 0 breaking changes, adds lots of value with very little code. Hope to get this merged :) |
Gonna close and re-open this to jumpstart the stuck tests. |
plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moory-se I figured out how to make the old legacy widgets available for testing, and I updated your testing instructions accordingly. Filter works fine in testing 👍
Could you explain a bit more about why the block version can't handle ~850 attributes, but the old legacy version can? I think this would be good feedback for our blocks teams. |
plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php
Outdated
Show resolved
Hide resolved
…av-filters.php Fix linter error
Doing it "manually" - in the UI - is a nightmare. It takes ~50 seconds to load the page with all the blocks. I have not digged very deep to debug this (we simply installed Classic Widgets and get on with our lives), so I'm not really sure why. I think it's partially due to the way blocks are stored, and partially because of the rendering process is not optimized for these volumes. I would guess the latter is the major part. To fix this, we actually add them by code. The Also, adding custom fields (such as a tooltip) to any widget is very simple with the classic widgets. We've actually developed a custom system (outside woocommerce/wordpress) to manage all the filters/layered navigation, and the data/configuration is exported to woocommerce for rendering. I think this is the only way to handle many filters in woocommerce, as opposed to many other platforms where they are configured on attribute ("use as filter") and/or category ("attributes to use for filtering on this category") level. |
Thanks! I'll pass this along. |
Submission Review Guidelines:
Changes proposed in this Pull Request:
Allow developers to change the anchor text of active filters. Often, one would add the taxonomy (
Brand: Adidas
).How to test the changes in this Pull Request:
Changelog entry
Significance
Type
Message
Add a filter to allow modifying the attribute term name in the Active Product Filters widget.
Comment