-
Notifications
You must be signed in to change notification settings - Fork 10.8k
[Experimental] Render ProductFilterTaxonomy block on the frontend #59589
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
[Experimental] Render ProductFilterTaxonomy block on the frontend #59589
Conversation
ef2052e
to
70ee4d5
Compare
70ee4d5
to
35595fb
Compare
Testing GuidelinesHi @ralucaStan , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
Size Change: +72 B (0%) Total Size: 5.91 MB |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
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.
I tested the PR and found interesting case, where I could only add:
- Brands Filter
- Tags Filter
but no Categories Filter.
Inserter | Inspector Controls |
---|---|
![]() |
![]() |
After syncing with @dinhtungdu to debug, we found out there's a bug in get_taxonomies
function. They're being queried by 'object_type' => array( 'product' ),
but plugins may change/extend the object_type
and as an example, I had Product Add Ons plugin activated, which resulted in product_cat
object_type
being an array:
[object_type] => Array
(
[0] => product
[1] => global_product_addon
)
and filters out product_cat
from query.
Anyway, I tested the PR after disabling the plugin and I consider the above issue a separate one (to be addressed in separate PR) hence pre-approving! ✅
Tested:
- Filters display correct data in both: list and chips
- Filters can be mixed with each other
- Filters display correct amount of products
Minor issue I found is incorrect char decoding, &
is correctly displayed in filter chips but incorrectly in Active Filters
Chip | Active Filter |
---|---|
![]() |
![]() |
* @param WP_Block $block Block instance. | ||
* @return string Rendered block type output. | ||
*/ | ||
protected function render( $block_attributes, $content, $block ) { |
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.
A lot is happening in render
method and it takes time to get it. I appreciate the comments before each section but would you consider splitting it into methods? Not a must but from a reviewer perspective (or later someone who's gonna read this) it may be easier to digest the content. 😄
I don't consider it a must, especially that it's WIP and you may be still evolving this class so it's up to you as you know the context and plans 🙌
@kmanijak I fixed the issue with the taxonomy query, we should have correct taxonomies now with any extension activated. About the encoding issue, it's an issue with Active filter data, so I will address that in a follow-up. About splitting the big render function, as I talked in our sync, for now, I prefer the big method over splitting it into multiple private methods, which are used only once. You can go through the whole method in one go and understand what it's doing instead of jumping back and forth between smaller methods. It may change along the way, but for now, let's keep this big boy. |
c503a54
to
7a23061
Compare
a565bbb
to
45bc43a
Compare
7a23061
to
6576675
Compare
45bc43a
to
ad97bba
Compare
- Add get_taxonomy_term_counts method with FilterData integration - Include necessary imports for ProductCollectionUtils and FilterData classes - Add circular counting prevention for attribute filters - Add placeholder render method for future implementation
- Add full frontend rendering logic similar to ProductFilterAttribute - Handle taxonomy validation and term retrieval with proper ordering/sorting - Implement selected term detection from filter parameters - Build filter context and options for inner blocks - Add interactive wrapper attributes for frontend filtering - Handle empty state with proper hiding - Include proper error handling and early exit conditions - All linting issues resolved
- Validate taxonomy exists in parameter map before expensive operations - Prevents unnecessary term counting when taxonomy not configured - Removes duplicate container/params_handler initialization - Improves performance by failing fast on invalid configurations
- Handle taxonomy filter type in frontend.ts parameter building - Add URL parameter mapping for taxonomy filters using filter_taxonomy format - Include TODO note for future refactoring to use centralized Params class - Enables frontend interaction for ProductFilterTaxonomy blocks
Replace hardcoded filter_taxonomy format with centralized parameter mapping from Params class. This ensures consistent URL parameter generation across the system and allows for custom taxonomy parameter names like 'categories' for product_cat.
ad97bba
to
a76b06b
Compare
📝 WalkthroughWalkthroughThis change updates the WooCommerce Product Filters functionality by enhancing taxonomy filter handling. The frontend logic now dynamically maps taxonomy filter parameters, while the backend Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend (JS)
participant Backend (PHP Block)
participant WooCommerce Data Providers
User->>Frontend (JS): Selects taxonomy filter
Frontend (JS)->>Frontend (JS): Map taxonomy filter to param key via config
Frontend (JS)->>Backend (PHP Block): Request filtered products with taxonomy params
Backend (PHP Block)->>Backend (PHP Block): prepare_selected_filters() processes params
Backend (PHP Block)->>WooCommerce Data Providers: get_taxonomy_term_counts()
WooCommerce Data Providers-->>Backend (PHP Block): Return term counts
Backend (PHP Block)->>Frontend (JS): Render block with filter context and counts
Estimated code review effort4 (~75 minutes) Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
📓 Path-based instructions (2)**/*.{php,js,jsx,ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
Files:
**/*.{php,js,ts,jsx,tsx}⚙️ CodeRabbit Configuration File
Files:
🧠 Learnings (2)📓 Common learnings
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (8)Learnt from: dinhtungdu Learnt from: samueljseay Learnt from: gigitux Learnt from: Aljullu Learnt from: senadir Learnt from: CR Learnt from: vladolaru Learnt from: samueljseay 🪛 PHPMD (2.15.0)plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php115-115: Avoid unused parameters such as '$content'. (Unused Code Rules) (UnusedFormalParameter) 🧰 Additional context used📓 Path-based instructions (2)**/*.{php,js,jsx,ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
Files:
**/*.{php,js,ts,jsx,tsx}⚙️ CodeRabbit Configuration File
Files:
🧠 Learnings (2)📓 Common learnings
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (8)Learnt from: dinhtungdu Learnt from: samueljseay Learnt from: gigitux Learnt from: Aljullu Learnt from: senadir Learnt from: CR Learnt from: vladolaru Learnt from: samueljseay 🪛 PHPMD (2.15.0)plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php115-115: Avoid unused parameters such as '$content'. (Unused Code Rules) (UnusedFormalParameter) 🔇 Additional comments (4)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 4
🧹 Nitpick comments (2)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (2)
129-135
: Consider caching the params handler for repeated use.The params handler is retrieved multiple times across different methods. Consider storing it as a class property to avoid repeated container lookups.
Add a class property and initialize it once:
+ /** + * Parameters handler instance. + * + * @var \Automattic\WooCommerce\Internal\ProductFilters\Params + */ + private $params_handler; + /** * Initialize this block type. * * - Hook into WP lifecycle. * - Register the block with WordPress. */ protected function initialize() { parent::initialize(); + $container = wc_get_container(); + $this->params_handler = $container->get( \Automattic\WooCommerce\Internal\ProductFilters\Params::class ); + add_filter( 'woocommerce_blocks_product_filters_selected_items', array( $this, 'prepare_selected_filters' ), 10, 2 ); }Then use
$this->params_handler
instead of retrieving it from the container each time.
293-299
: Remove unused variable from foreach loop.The
$param_key
variable is not used within the loop body.- foreach ( $taxonomy_params as $taxonomy_slug => $param_key ) { + foreach ( array_keys( $taxonomy_params ) as $taxonomy_slug ) { $taxonomy = get_taxonomy( $taxonomy_slug ); if ( ! $taxonomy ) { continue; }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
(2 hunks)plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
(3 hunks)
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
**/*.{php,js,jsx,ts,tsx}
: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable
Files:
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
**/*.{php,js,ts,jsx,tsx}
⚙️ CodeRabbit Configuration File
**/*.{php,js,ts,jsx,tsx}
: Don't trust that extension developers will follow the best practices, make sure the code:
- Guards against unexpected inputs.
- Sanitizes and validates any potentially dangerous inputs.
- Is backwards compatible.
- Is readable and intuitive.
- Has unit or E2E tests where applicable.
Files:
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
🧠 Learnings (3)
📓 Common learnings
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-07-21T05:22:46.417Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using `wc_string_to_bool()` over `filter_var($value, FILTER_VALIDATE_BOOLEAN)` when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts (9)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: ralucaStan
PR: #58782
File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/customer-address.tsx:76-90
Timestamp: 2025-06-13T13:37:35.793Z
Learning: In plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/customer-address.tsx, the shouldAnimate
flag is expected to be false
only on initial render and may remain true
after the first edit; it does not need to be reset.
Learnt from: samueljseay
PR: #59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }
- defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/woo-build.mdc:0-0
Timestamp: 2025-07-18T14:55:02.778Z
Learning: To watch for changes during development, use 'pnpm --filter=@woocommerce/plugin-woocommerce watch:build' to ensure experimental features are active.
Learnt from: ralucaStan
PR: #58782
File: plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-details/style.scss:21-26
Timestamp: 2025-06-13T15:24:45.923Z
Learning: In WooCommerce blocks, bold styling for .wc-block-components-product-details__name
should be scoped only to the Cart block (.wc-block-cart__main
); on the Checkout block, product names are not bold because prices are highlighted instead.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (5)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: samueljseay
PR: #59142
File: plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php:594-602
Timestamp: 2025-06-25T06:51:41.381Z
Learning: WooCommerce block templates have a predictable structure where each block has one top-level div with wp-block-woocommerce- class containing arbitrary nested content that should be preserved.
🪛 PHPMD (2.15.0)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
115-115: Avoid unused parameters such as '$content'. (Unused Code Rules)
(UnusedFormalParameter)
293-293: Avoid unused local variables such as '$param_key'. (Unused Code Rules)
(UnusedLocalVariable)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
**/*.{php,js,jsx,ts,tsx}
: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable
Files:
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
**/*.{php,js,ts,jsx,tsx}
⚙️ CodeRabbit Configuration File
**/*.{php,js,ts,jsx,tsx}
: Don't trust that extension developers will follow the best practices, make sure the code:
- Guards against unexpected inputs.
- Sanitizes and validates any potentially dangerous inputs.
- Is backwards compatible.
- Is readable and intuitive.
- Has unit or E2E tests where applicable.
Files:
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
🧠 Learnings (3)
📓 Common learnings
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-07-21T05:22:46.417Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using `wc_string_to_bool()` over `filter_var($value, FILTER_VALIDATE_BOOLEAN)` when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts (9)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: ralucaStan
PR: #58782
File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/customer-address.tsx:76-90
Timestamp: 2025-06-13T13:37:35.793Z
Learning: In plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/customer-address.tsx, the shouldAnimate
flag is expected to be false
only on initial render and may remain true
after the first edit; it does not need to be reset.
Learnt from: samueljseay
PR: #59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }
- defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/woo-build.mdc:0-0
Timestamp: 2025-07-18T14:55:02.778Z
Learning: To watch for changes during development, use 'pnpm --filter=@woocommerce/plugin-woocommerce watch:build' to ensure experimental features are active.
Learnt from: ralucaStan
PR: #58782
File: plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-details/style.scss:21-26
Timestamp: 2025-06-13T15:24:45.923Z
Learning: In WooCommerce blocks, bold styling for .wc-block-components-product-details__name
should be scoped only to the Cart block (.wc-block-cart__main
); on the Checkout block, product names are not bold because prices are highlighted instead.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (5)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: samueljseay
PR: #59142
File: plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php:594-602
Timestamp: 2025-06-25T06:51:41.381Z
Learning: WooCommerce block templates have a predictable structure where each block has one top-level div with wp-block-woocommerce- class containing arbitrary nested content that should be preserved.
🪛 PHPMD (2.15.0)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
115-115: Avoid unused parameters such as '$content'. (Unused Code Rules)
(UnusedFormalParameter)
293-293: Avoid unused local variables such as '$param_key'. (Unused Code Rules)
(UnusedLocalVariable)
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
Outdated
Show resolved
Hide resolved
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (1)
287-310
: Remove unused variable assignment.The
$param_key
variable is extracted in the foreach loop but never used, as flagged by static analysis.- foreach ( $taxonomy_params as $taxonomy_slug => $param_key ) { + foreach ( $taxonomy_params as $taxonomy_slug => $_param_key ) {Or simply use
array_keys()
if only the taxonomy slug is needed:- foreach ( $taxonomy_params as $taxonomy_slug => $param_key ) { + foreach ( array_keys( $taxonomy_params ) as $taxonomy_slug ) {
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
(2 hunks)plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
(3 hunks)
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
**/*.{php,js,jsx,ts,tsx}
: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
**/*.{php,js,ts,jsx,tsx}
⚙️ CodeRabbit Configuration File
**/*.{php,js,ts,jsx,tsx}
: Don't trust that extension developers will follow the best practices, make sure the code:
- Guards against unexpected inputs.
- Sanitizes and validates any potentially dangerous inputs.
- Is backwards compatible.
- Is readable and intuitive.
- Has unit or E2E tests where applicable.
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
🧠 Learnings (2)
📓 Common learnings
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-07-21T05:22:46.417Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using `wc_string_to_bool()` over `filter_var($value, FILTER_VALIDATE_BOOLEAN)` when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (8)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: senadir
PR: #59426
File: plugins/woocommerce/client/legacy/js/frontend/a8c-address-autocomplete-service.js:355-355
Timestamp: 2025-07-08T09:14:47.894Z
Learning: In the WooCommerce address autocomplete system, input sanitization happens upstream in address-autocomplete.js before data reaches a8c-address-autocomplete-service.js. The trim() operation in the service file is for optimization purposes (to skip API requests when only spaces are added), not for security sanitization.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/code-quality.mdc:0-0
Timestamp: 2025-07-18T14:54:36.232Z
Learning: Applies to **/*.{php,js,jsx,ts,tsx} : Sanitize and validate any potentially dangerous inputs
Learnt from: vladolaru
PR: #58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using wc_string_to_bool()
over filter_var($value, FILTER_VALIDATE_BOOLEAN)
when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: samueljseay
PR: #59142
File: plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php:594-602
Timestamp: 2025-06-25T06:51:41.381Z
Learning: WooCommerce block templates have a predictable structure where each block has one top-level div with wp-block-woocommerce- class containing arbitrary nested content that should be preserved.
🪛 PHPMD (2.15.0)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
115-115: Avoid unused parameters such as '$content'. (Unused Code Rules)
(UnusedFormalParameter)
293-293: Avoid unused local variables such as '$param_key'. (Unused Code Rules)
(UnusedLocalVariable)
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
**/*.{php,js,jsx,ts,tsx}
: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
**/*.{php,js,ts,jsx,tsx}
⚙️ CodeRabbit Configuration File
**/*.{php,js,ts,jsx,tsx}
: Don't trust that extension developers will follow the best practices, make sure the code:
- Guards against unexpected inputs.
- Sanitizes and validates any potentially dangerous inputs.
- Is backwards compatible.
- Is readable and intuitive.
- Has unit or E2E tests where applicable.
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
🧠 Learnings (2)
📓 Common learnings
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-07-21T05:22:46.417Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using `wc_string_to_bool()` over `filter_var($value, FILTER_VALIDATE_BOOLEAN)` when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (8)
Learnt from: dinhtungdu
PR: #59499
File: plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php:327-332
Timestamp: 2025-07-10T04:22:27.648Z
Learning: In the WooCommerce ProductFilters QueryClauses class, the $chosen_taxonomies parameter in add_taxonomy_clauses() already contains only validated public product taxonomies. The validation occurs upstream in the Params class during parameter registration, so additional taxonomy existence validation in the processing methods is redundant.
Learnt from: samueljseay
PR: #58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: Aljullu
PR: #58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
, the team intentionally relies on toggling the disabled
CSS class (via data-wp-class--disabled
) instead of binding the disabled
attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: gigitux
PR: #58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in ProductSpecifications.php
) adds specific classes to the output. If so, add those same classes to the useBlockProps
className in the editor component (like in edit.tsx
) to ensure consistent styling. For example, adding wp-block-table
class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Learnt from: senadir
PR: #59426
File: plugins/woocommerce/client/legacy/js/frontend/a8c-address-autocomplete-service.js:355-355
Timestamp: 2025-07-08T09:14:47.894Z
Learning: In the WooCommerce address autocomplete system, input sanitization happens upstream in address-autocomplete.js before data reaches a8c-address-autocomplete-service.js. The trim() operation in the service file is for optimization purposes (to skip API requests when only spaces are added), not for security sanitization.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/code-quality.mdc:0-0
Timestamp: 2025-07-18T14:54:36.232Z
Learning: Applies to **/*.{php,js,jsx,ts,tsx} : Sanitize and validate any potentially dangerous inputs
Learnt from: vladolaru
PR: #58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using wc_string_to_bool()
over filter_var($value, FILTER_VALIDATE_BOOLEAN)
when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
Learnt from: samueljseay
PR: #59142
File: plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php:594-602
Timestamp: 2025-06-25T06:51:41.381Z
Learning: WooCommerce block templates have a predictable structure where each block has one top-level div with wp-block-woocommerce- class containing arbitrary nested content that should be preserved.
🪛 PHPMD (2.15.0)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php
115-115: Avoid unused parameters such as '$content'. (Unused Code Rules)
(UnusedFormalParameter)
293-293: Avoid unused local variables such as '$param_key'. (Unused Code Rules)
(UnusedLocalVariable)
🔇 Additional comments (4)
plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php (4)
28-32
: LGTM! Clean initialization pattern.The method correctly follows WordPress initialization patterns by calling the parent method first and properly registering the filter hook.
58-105
: LGTM! Security concerns addressed and efficient implementation.The method correctly:
- Uses centralized parameter mapping from the Params handler
- Sanitizes term slugs with
sanitize_title()
(addressing previous security concerns)- Performs a single query for all terms to avoid N+1 query problems
- Handles WP_Error cases appropriately
The implementation follows WooCommerce patterns and efficiently processes active filters.
115-232
: LGTM! Comprehensive rendering logic with proper validation.The render method correctly:
- Validates context and taxonomy existence before processing
- Uses centralized parameter mapping for consistency
- Sanitizes user input with
sanitize_title()
(addressing previous security concerns)- Configures frontend interactivity properly
- Handles empty states and error conditions
- Follows WordPress block rendering patterns
Note: The unused
$content
parameter warning from static analysis is expected in WordPress block render methods and can be ignored.
241-280
: LGTM! Correct implementation of term count logic.The method properly:
- Removes current taxonomy from query vars to prevent circular counting
- Handles product attribute filters (pa_ prefix) to ensure accurate cross-filter counting
- Uses existing utilities (
ProductCollectionUtils::remove_query_array
)- Leverages the centralized
FilterDataProvider
serviceThe implementation correctly addresses the circular counting issue referenced in the GitHub PR.
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR implements the frontend rendering functionality for the ProductFilterTaxonomy block including displaying the options and interacting with options.
Closes WOOPLUG-4767
Closes #59131
Screenshots or screen recordings:
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment
Experimental - Render ProductFilterTaxonomy block on the frontend frontend