Skip to content

[Backport to release/11.1] Include product brands in term recounts - #67656

Merged
gigitux merged 1 commit into
release/11.1from
cherry-pick-PR67630-to-release/11.1
Aug 12, 2026
Merged

[Backport to release/11.1] Include product brands in term recounts#67656
gigitux merged 1 commit into
release/11.1from
cherry-pick-PR67630-to-release/11.1

Conversation

@woocommercebot

Copy link
Copy Markdown
Collaborator

This PR is a cherry-pick of #67630 to release/11.1.

Original PR Description

Submission Review Guidelines:

Changes proposed in this Pull Request:

Product brands currently maintain visibility-aware term counts through separate WC_Brands callbacks. This means callers of the shared WooCommerce recount functions update product categories and tags but can leave brand counts stale. It also makes normal stock and inventory-setting updates run a second, Brands-only recount after the shared recount.

This PR:

  • includes product_brand in the deferred stock recount path;
  • includes all product brands in wc_recount_all_terms();
  • includes a product's brands and brand ancestors in _wc_recount_terms_by_product();
  • removes WooCommerce's duplicate Brands callback registrations; and
  • extends the term-function test coverage to product brands.

The existing public WC_Brands::recount_after_stock_change() and WC_Brands::recount_all_brands() methods remain unchanged for direct callers.

I found this opportunity, while I was working on #67624.

How to test the changes in this Pull Request:

  1. Create a product category, a product tag, a parent product brand, and a child brand.
  2. Create two products and assign both to the category, tag, and child brand:
    • Keep the first product in stock.
    • Set the second product to out of stock.
  3. Enable Hide out of stock items from the catalog under WooCommerce > Settings > Products > Inventory.
  4. Check the term counts under Products > Categories, Products > Tags, and Products > Brands. Confirm the category, tag, parent brand, and child brand each have a count of 1.
  5. Change the in-stock product to out of stock. Confirm all four counts change to 0.
  6. Change the other product to in stock. Confirm all four counts return to 1.

Milestone

Changelog entry

A patch/fix changelog entry was created manually at plugins/woocommerce/changelog/fix-product-brand-term-recounts.

Release Communication

Select if this PR needs a generated summary for release notes:

  • Feature Highlight - For user-facing features (what changed, user impact)
  • Developer Advisory - For developer-facing changes (what changed, how to detect, actions needed)

Use of AI Tools

OpenAI Codex was used to implement the changes, extend the tests, run validation, and draft this pull request description. The contributor remains responsible for reviewing and maintaining the submitted code.

* Include product brands in term recounts

* Add changelog for product brand recounts
@woocommercebot
woocommercebot requested a review from gigitux August 12, 2026 12:41
@github-actions github-actions Bot added this to the 11.1.0 milestone Aug 12, 2026
@github-actions github-actions Bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Testing Guidelines

Hi @gigitux ,

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:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@github-actions

Copy link
Copy Markdown
Contributor

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

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 commit that changes plugin code.

@gigitux gigitux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@gigitux
gigitux merged commit fc7adf2 into release/11.1 Aug 12, 2026
47 of 49 checks passed
@gigitux
gigitux deleted the cherry-pick-PR67630-to-release/11.1 branch August 12, 2026 14:21
@github-actions github-actions Bot added the metric: feature freeze exception A tracking label for PRs that were merged after the feature freeze. label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metric: feature freeze exception A tracking label for PRs that were merged after the feature freeze. plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo