-
Notifications
You must be signed in to change notification settings - Fork 835
Instant Search: Add WC Global Product Attributes as Filters #45416
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
base: trunk
Are you sure you want to change the base?
Conversation
This initial commit replicates the existing Taxonomy filter setup to add a new "Product Attributes" filter. This filter will display global WooCommerce attributes only.
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Search plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 7 files. Only the first 5 are listed here.
Full summary · PHP report · JS report Coverage check overridden by
Coverage tests to be added later
|
- Ensure we're retrieving product attributes correctly - Ensure we don't miss the 'case' statement needed in class-inline-search.php
Some method cleanup and PHAN ignores following existence checks
- Refactor class-search-widget.php to remove unnecessary PHP tags - Update class-search-widget.php product_attribute case to move where 'count' attribute is added - Refactor get_filters_from_widgets() to separate concerns - Fix product_attribute case in class-classic-search.php to prevent slugs from being re-added to an array unnecessarily
- Create tests/php/woocommerce-mocks.php with mock functions - Remove eval() calls from product attribute tests - Mock functions defined in global namespace for proper testing - Test expansion of generic product_attribute filters into specific attributes - Test preservation of specific product_attribute filters (no expansion) - Test included_attributes filtering to limit expansion - Verify property inheritance (widget_id, count, name) - Add helper methods for product attribute filter data providers
Implements #21216, cf. SEARCH-83
Proposed changes:
Note
I have included tests in this PR, but I appreciate that this has increased the number of lines changed and has an impact on review burden. If deemed appropriate I can remove the tests from this PR and include them in their own, subsequent PR.
This PR adds a new "Product Attributes" (PAs) option alongside the existing Jetpack Search Filter Widget filters. By default, all PAs will show in the Jetpack Search Sidebar, though selecting any PA from the checkbox list (currently formatted to show in a 3byX grid) will limit the filters to only those selected. If a user selects all checkboxes, there is logic in place to avoid O(n^2).
The filters show as follows. In this case, the attribute name takes the place of the filter title, so no title is offered for this particular filter widget.
Other information:
Jetpack product discussion
No
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Note
This PR requires a test site with WooCommerce test data at a minimum. In addition, some of the test site's products must have global attributes assigned. The site must also be indexed using the PR at 193759-ghe-Automattic/wpcom to index.
For information on PAs, see https://woocommerce.com/document/managing-product-taxonomies/#product-attributes. Global Attributes can added at Products --> Attributes, and then assigned on a per-product basis.
composer run test-php
andcomposer run test-js
both pass