From d0db74edd5804bfc6d89a9cd1410daabcb811b28 Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 31 Aug 2018 19:10:32 +0200 Subject: [PATCH 1/3] Fix variable product cache misses If the child product doesn't have weight or dimensions, the value is not being cached correctly as a ```false``` value is being stored and it always recheck that on every page load. --- includes/class-wc-product-variable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index c0d10a4078d..12de1b68ed7 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -504,7 +504,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_weight ) { $has_weight = $this->data_store->child_has_weight( $this ); - set_transient( $transient_name, $has_weight, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, (int) $has_weight, DAY_IN_SECONDS * 30 ); } return (bool) $has_weight; @@ -521,7 +521,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_dimension ) { $has_dimension = $this->data_store->child_has_dimensions( $this ); - set_transient( $transient_name, $has_dimension, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, (int) $has_dimension, DAY_IN_SECONDS * 30 ); } return (bool) $has_dimension; From 081125043d7e2500ec9789e6e04ea520b95361cb Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 31 Aug 2018 19:12:12 +0200 Subject: [PATCH 2/3] wordpress coding standards --- includes/class-wc-product-variable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index 12de1b68ed7..e8b4693e881 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -504,7 +504,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_weight ) { $has_weight = $this->data_store->child_has_weight( $this ); - set_transient( $transient_name, (int) $has_weight, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, ( int ) $has_weight, DAY_IN_SECONDS * 30 ); } return (bool) $has_weight; @@ -521,7 +521,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_dimension ) { $has_dimension = $this->data_store->child_has_dimensions( $this ); - set_transient( $transient_name, (int) $has_dimension, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, ( int ) $has_dimension, DAY_IN_SECONDS * 30 ); } return (bool) $has_dimension; From 0a0f733a6effe9e4c34b3943c96a0985f561f085 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 6 Sep 2018 22:52:48 +0200 Subject: [PATCH 3/3] fix lint code style issue --- includes/class-wc-product-variable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index e8b4693e881..12de1b68ed7 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -504,7 +504,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_weight ) { $has_weight = $this->data_store->child_has_weight( $this ); - set_transient( $transient_name, ( int ) $has_weight, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, (int) $has_weight, DAY_IN_SECONDS * 30 ); } return (bool) $has_weight; @@ -521,7 +521,7 @@ class WC_Product_Variable extends WC_Product { if ( false === $has_dimension ) { $has_dimension = $this->data_store->child_has_dimensions( $this ); - set_transient( $transient_name, ( int ) $has_dimension, DAY_IN_SECONDS * 30 ); + set_transient( $transient_name, (int) $has_dimension, DAY_IN_SECONDS * 30 ); } return (bool) $has_dimension;