litespeedtech / litespeedtech/lscache_wp

WooCommerce stock status purge does not include Product Brand archives

Open
#1,042 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
257
Forks
123
PR merge metrics
No merged PRs in 30d

Description

Hi,

I originally reported this in the WordPress.org support forum, where it was forwarded to the development team. I thought it would also be useful to open an issue here, as GitHub may be the most convenient place to track whether the suggestion progresses.

Related WordPress.org support discussion:

https://wordpress.org/support/topic/woocommerce-stock-status-purge-does-not-include-product-brand-archives/

I would like to suggest a small compatibility improvement to LiteSpeed Cache’s WooCommerce purge logic.

Now that Product Brands (`product_brand`) are included in WooCommerce core, it would make sense to treat brand archives alongside the other core WooCommerce product taxonomies when a product’s stock status changes.

When using the LiteSpeed Cache setting:

> Purge product on changes to the quantity or stock status. Purge categories only when stock status changes.

LiteSpeed Cache correctly purges the product and its related product category archives when the stock status changes. However, the related Product Brand archive does not appear to be included in the purge.

This can leave a cached brand archive outdated after changes such as:

- `instock` → `outofstock`
- `outofstock` → `instock`

The issue is especially noticeable when WooCommerce is configured to hide out-of-stock products or when the product listing otherwise depends on stock status.

### Suggested behavior

Could `product_brand` be included in the same stock-status purge logic as `product_cat`?

Ideally, brand archives would be purged when the stock status changes, but not unnecessarily after ordinary quantity changes when the selected LiteSpeed setting is configured to purge categories only on stock status changes.

The current WooCommerce integration appears to handle `product_cat` and `product_tag` here, but not the WooCommerce core `product_brand` taxonomy:

https://github.com/litespeedtech/lscache_wp/blob/master/thirdparty/woocommerce.cls.php#L3664-L3706

Variations would also need to resolve to their parent product, since the brand is normally assigned to the parent product.

This has been reproduced using the latest available versions of WordPress, WooCommerce, and LiteSpeed Cache for WordPress.

A custom hook can be used as a workaround, but since Product Brands are now part of WooCommerce core, handling them directly in LiteSpeed Cache’s WooCommerce integration would prevent each store from needing its own custom purge logic.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in thirdparty/woocommerce.cls.php around lines 3664-3706 and compare the existing product_cat and product_tag handling. Trace how stock-status changes and variations resolve their products, then verify that product_brand archives are purged on stock changes without being purged for ordinary quantity changes under the stated setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.