WooCommerce 10.5, scheduled for February 2026, will introduce improvements to how variation prices are cached, along with a new utility class for working with callbacks. Extension developers who modify variation prices dynamically should review this advisory.
The Details
WooCommerce uses transient caching for variation prices to improve performance. The cache key hash includes information about filters hooked to woocommerce_variation_prices_price, woocommerce_variation_prices_regular_price, and woocommerce_variation_prices_sale_price.
Currently, when generating this hash WooCommerce serializes entire callback objects. This means that any change in an object’s properties—even those unrelated to pricing—will invalidate the cache, causing unnecessary performance overhead.
This pull request introduces two key changes:
- A new CallbackUtil class (
Automattic\WooCommerce\Utilities\CallbackUtil) that generates stable callback signatures based only on class names and method names, not object state. - A new filter:
woocommerce_use_legacy_get_variations_price_hashthat controls which algorithm is used for cache hash generation.
The new woocommerce_use_legacy_get_variations_price_hash filter currently returns true by default, meaning that the old algorithm (full callback serialization) will still be used if the filter is not hooked into. However, we plan to change it so it defaults to false in WooCommerce 11.0, scheduled for release in August 2026.
How can I tell if this affects me?
As an extension developer, this affects you if your extension:
- Hooks into
woocommerce_variation_prices_price(or the regular/sale price equivalents) to modify variation prices. - Returns prices that vary based on any dynamic factor (current user, user role, time of day, cart contents, etc.)
- Does NOT currently hook into
woocommerce_get_variation_prices_hashto account for these factors.
As a shop owner, this affects you if:
- You’re experiencing slow page loads on variable product pages.
- You have extensions that dynamically modify variation prices.
What action should I take?
For Extension Developers
1. If you hook into variation price filters with dynamic pricing, you MUST also hook into woocommerce_get_variation_prices_hash. Here’s an example for price variation by user:
class My_Custom_Pricing {
public function __construct() {
add_filter( 'woocommerce_variation_prices_price', array( $this, 'apply_user_discount' ), 10, 3 );
add_filter( 'woocommerce_get_variation_prices_hash', array( $this, 'add_user_to_hash' ), 10, 3 );
}
public function apply_user_discount( $price, $variation, $product ) {
return $price * $this->get_discount_for_user( get_current_user_id() );
}
public function add_user_to_hash( $price_hash, $product, $for_display ) {
$price_hash[] = get_current_user_id();
return $price_hash;
}
}You should update your extension before August 2026, since that’s where WooCommerce 11.0 with the change in the default value for the woocommerce_use_legacy_get_variations_price_hash filter will be released.
2. Use the new CallbackUtil class when you need a serialized representation of a callback in your own code:
use Automattic\WooCommerce\Utilities\CallbackUtil;
// Get a stable signature for any callback
$signature = CallbackUtil::get_callback_signature( $my_callback );
// Get signatures for all callbacks on a hook
$signatures = CallbackUtil::get_hook_callback_signatures( 'my_hook_name' );For Shop Owners
A new woocommerce_use_legacy_get_variations_price_hash filter has been introduced. It defaults to true (legacy behavior) for backwards compatibility.
If you want to benefit from the improved variation prices caching now (as soon as WooCommerce 10.5 is released), and you’re confident that all your installed plugins properly use woocommerce_get_variation_prices_hash together with woocommerce_get_variation_prices_hash when needed, you can enable the new behavior:
add_filter( 'woocommerce_use_legacy_get_variations_price_hash', '__return_true' );On the other hand, if after updating to WooCommerce 11.0 you find issues with variation prices and you suspect that these are caused by a misbehaving extension, you can set the filter to '__return_false' to restore the old behavior.
In testing with a product containing 800 variations, this change reduced get_variation_prices() execution time from ~500ms to 40-50ms on cached requests.
Leave a Reply