diff --git a/includes/admin/class-wc-admin-status.php b/includes/admin/class-wc-admin-status.php index 99c40f4ce9a..8414f821d0f 100644 --- a/includes/admin/class-wc-admin-status.php +++ b/includes/admin/class-wc-admin-status.php @@ -107,8 +107,6 @@ class WC_Admin_Status { _wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false ); - delete_transient( 'wc_term_counts' ); - echo '

' . __( 'Terms successfully recounted', 'woocommerce' ) . '

'; break; case 'clear_sessions' : diff --git a/includes/admin/class-wc-admin-taxonomies.php b/includes/admin/class-wc-admin-taxonomies.php index b3e98c49c1c..1676b2bac5e 100644 --- a/includes/admin/class-wc-admin-taxonomies.php +++ b/includes/admin/class-wc-admin-taxonomies.php @@ -254,13 +254,13 @@ class WC_Admin_Taxonomies { * @return void */ public function save_category_fields( $term_id, $tt_id, $taxonomy ) { - if ( isset( $_POST['display_type'] ) ) + if ( isset( $_POST['display_type'] ) ) { update_woocommerce_term_meta( $term_id, 'display_type', esc_attr( $_POST['display_type'] ) ); + } - if ( isset( $_POST['product_cat_thumbnail_id'] ) ) + if ( isset( $_POST['product_cat_thumbnail_id'] ) ) { update_woocommerce_term_meta( $term_id, 'thumbnail_id', absint( $_POST['product_cat_thumbnail_id'] ) ); - - delete_transient( 'wc_term_counts' ); + } } /** diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php index 1de56ea2e20..920014f7d5d 100644 --- a/includes/wc-term-functions.php +++ b/includes/wc-term-functions.php @@ -497,6 +497,8 @@ function _wc_term_recount( $terms, $taxonomy, $callback = true, $terms_are_term_ // Update the count update_woocommerce_term_meta( $term_id, 'product_count_' . $taxonomy->name, absint( $count ) ); } + + delete_transient( 'wc_term_counts' ); } /** @@ -525,8 +527,6 @@ function wc_recount_after_stock_change( $product_id ) { _wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), false, false ); } - - delete_transient( 'wc_term_counts' ); } add_action( 'woocommerce_product_set_stock_status', 'wc_recount_after_stock_change' );