woocommerce_variation_prices filter runs only for the first hashed prices array loaded from the transient

This commit is contained in:
Manos Psychogyiopoulos 2016-05-25 00:54:07 +03:00
parent 8709d31f41
commit 35ff166a85
1 changed files with 6 additions and 6 deletions

View File

@ -258,15 +258,15 @@ class WC_Product_Variable extends WC_Product {
if ( empty( $this->prices_array[ $price_hash ] ) ) {
// Get value of transient
$this->prices_array = array_filter( (array) json_decode( strval( get_transient( $transient_name ) ), true ) );
$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' ) ) {
if ( empty( $prices_array['version'] ) || $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 ] ) ) {
if ( empty( $prices_array[ $price_hash ] ) ) {
$prices = array();
$regular_prices = array();
$sale_prices = array();
@ -311,19 +311,19 @@ class WC_Product_Variable extends WC_Product {
asort( $regular_prices );
asort( $sale_prices );
$this->prices_array[ $price_hash ] = array(
$prices_array[ $price_hash ] = array(
'price' => $prices,
'regular_price' => $regular_prices,
'sale_price' => $sale_prices,
);
set_transient( $transient_name, json_encode( $this->prices_array ), DAY_IN_SECONDS * 30 );
set_transient( $transient_name, json_encode( $prices_array ), DAY_IN_SECONDS * 30 );
}
/**
* Give plugins one last chance to filter the variation prices array which has been generated.
*/
$this->prices_array[ $price_hash ] = apply_filters( 'woocommerce_variation_prices', $this->prices_array[ $price_hash ], $this, $display );
$this->prices_array[ $price_hash ] = apply_filters( 'woocommerce_variation_prices', $prices_array[ $price_hash ], $this, $display );
}
/**