Product version storage to invalidate cache when needed

#9922 for @daigo75
This commit is contained in:
Mike Jolley 2015-12-31 16:31:20 +00:00
parent 7c7e21be50
commit 8b9bdbb228
1 changed files with 5 additions and 0 deletions

View File

@ -271,6 +271,11 @@ class WC_Product_Variable extends WC_Product {
// Get value of transient
$this->prices_array = array_filter( (array) json_decode( strval( get_transient( $transient_name ) ), true ) );
// If the product version has changed, reset cache
if ( empty( $this->prices_array['version'] ) || $this->prices_array['version'] !== WC_Cache_Helper::get_transient_version( 'product' ) ) {
$this->prices_array = array( 'version' => WC_Cache_Helper::get_transient_version( 'product' ) );
}
// If the prices are not stored for this hash, generate them
if ( empty( $this->prices_array[ $price_hash ] ) ) {
$prices = array();