Skip to content

Conversation

anaemnesis
Copy link
Contributor

@anaemnesis anaemnesis commented Oct 8, 2025

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).

CleanShot 2025-10-14 at 13 44 22

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.

CleanShot 2025-10-13 at 20 34 31

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

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.

  • Navigate to Appearance --> Widgets and add a Jetpack Search widget (Legacy Widget)
  • Add a new filter, selecting 'Product Attributes' from the dropdown.
  • Test with both no attributes selected, all attributes selected, and only one or two attributes selected.
  • When you search for Products, you should see only PAs relevant to the returned results. If a given product has no PAs, no PAs should show as filters.
  • When you search for non-Products, you should not see any PAs as filters.
  • Make sure composer run test-php and composer run test-js both pass

This initial commit replicates the existing Taxonomy filter setup to
add a new "Product Attributes" filter. This filter will display
global WooCommerce attributes only.
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/instant-search-wc-attributes branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/instant-search-wc-attributes

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Package] Search Contains core Search functionality for Jetpack and Search plugins [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. labels Oct 8, 2025
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

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:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: November 4, 2025
    • Code freeze: November 3, 2025

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.

Copy link

jp-launch-control bot commented Oct 8, 2025

Code Coverage Summary

Coverage changed in 7 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/search/src/classic-search/class-classic-search.php 37/871 (4.25%) -0.35% 66 💔
projects/packages/search/src/widgets/class-search-widget.php 18/579 (3.11%) -0.24% 41 💔
projects/packages/search/src/inline-search/class-inline-search.php 161/288 (55.90%) -2.01% 10 💔
projects/packages/search/src/instant-search/components/search-filter.jsx 0/60 (0.00%) 0.00% 6 💔
projects/packages/search/src/class-helper.php 306/372 (82.26%) -0.36% 5 💔

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

- Ensure we're retrieving product attributes correctly
- Ensure we don't miss the 'case' statement needed in class-inline-search.php
@anaemnesis anaemnesis self-assigned this Oct 9, 2025
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
@anaemnesis anaemnesis added the Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR label Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Package] Search Contains core Search functionality for Jetpack and Search plugins [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant