Tweak wc_var_prices naming to allow them to be flushed on save

This commit is contained in:
Mike Jolley 2015-08-26 11:00:48 +01:00
parent ea3bebe301
commit 28da8a40d8
1 changed files with 10 additions and 7 deletions

View File

@ -255,13 +255,16 @@ class WC_Product_Variable extends WC_Product {
* @return array()
*/
public function get_variation_prices( $display = false ) {
$cache_key = 'wc_var_prices' . md5( json_encode( apply_filters( 'woocommerce_get_variation_prices_hash', array(
$this->id,
$display ? WC_Tax::get_rates() : '',
WC_Cache_Helper::get_transient_version( 'product' )
), $this, $display ) ) );
/**
* Create unique cache key based on the tax location (affects displayed/cached prices) and product version.
* Max transient length is 45, -10 for get_transient_version.
* @var string
*/
$hash = substr( md5( json_encode( apply_filters( 'woocommerce_get_variation_prices_hash', array( $this->id, $display ? WC_Tax::get_rates() : '' ), $this, $display ) ) ), 0, 22 );
$cache_key = 'wc_var_prices' . $hash . WC_Cache_Helper::get_transient_version( 'product' );
$prices_array = get_transient( $cache_key );
if ( false === ( $prices_array = get_transient( $cache_key ) ) ) {
if ( empty( $prices_array ) ) {
$prices = array();
$regular_prices = array();
$sale_prices = array();