Restore code to delete wc_layered_nav_counts_* transients
Commit a9994feeea
removed the code to delete wc_layered_nav_counts_* transients whenever a product attribute is updated and moved it to wc_delete_product_transients(). This was done to make sure those transients are deleted whenever a product is updated and not only when a product attribute changes. But, as Claudiu pointed out (https://github.com/woocommerce/woocommerce/pull/22029#issuecomment-451473512), this change introduced a bug as if you remove an attribute from a product, by the time the code reaches wc_delete_product_transients() the changes have been applied already to the product, the attribute doesn't belong to it anymore, and thus the layered nav counts transient for that attribute is not deleted.
To work around this problem, this commit restores the code that deletes wc_layered_nav_counts_* transients inside WC_Product_Data_Store_CPT::update_attributes(). Now, in most cases, WC will try to delete the same transient twice, but I can't see any other way to implement a solution for the problem above without doing this.
This commit is contained in:
parent
a9994feeea
commit
c82346b095
|
@ -738,6 +738,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
foreach ( $attributes as $attribute_key => $attribute ) {
|
||||
$value = '';
|
||||
|
||||
delete_transient( 'wc_layered_nav_counts_' . $attribute_key );
|
||||
|
||||
if ( is_null( $attribute ) ) {
|
||||
if ( taxonomy_exists( $attribute_key ) ) {
|
||||
// Handle attributes that have been unset.
|
||||
|
|
Loading…
Reference in New Issue