[Backport to release/10.1] Update OrderCountCache to return values for all previously saved statuses #60236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a cherry-pick of #60209 to
release/10.1
.Original PR Description
Changes proposed in this Pull Request:
This updates the
OrderCountCache::get()
method so that it returns all previously stored values for a given order type.Previously, if $order_statuses were not passed in, the list of statuses that would be fetched from cache would be based on the default list of statuses retrieved from
wc_get_order_statuses()
. This causes a backward compatibility issue with extensions like WooCommerce Subscriptions which doesn't register all of the statuses it uses to be returned bywc_get_order_statuses()
.This changes it so that the OrderCountCache will keep it's own list of saved statuses per order type allowing
OrderCountCache->get()
to return all previously saved counts for the order type.Partial Fix for WOOSUBS-867.
This specifically fixes an issue with WooCommerce Subscriptions when running object cache.
(For Bug Fixes) Bug introduced in PR #54034.
To See Previous Bug:
Screenshots or screen recordings:
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Note - The cached count shown within pagination WooCommerce Subscriptions does not get properly updated when a subscription is transitioned from one status to another. This is noted in https://github.com/woocommerce/woocommerce-subscriptions/pull/4973#issuecomment-3154877832. Because Woo Subscriptions overrides the transition method of its extended order, it will need to integrate cache incrementing itself.
Testing that has already taken place:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment