WC_Product_Data_Store_CPT::update_term_counts PHP Method

update_term_counts() protected method

Count terms. These are done at this point so all product props are set in advance.
Since: 2.7.0
protected update_term_counts ( &$product )
    protected function update_term_counts(&$product)
    {
        if (!wp_defer_term_counting()) {
            global $wc_allow_term_recount;
            $wc_allow_term_recount = true;
            $post_type = $product->is_type('variation') ? 'product_variation' : 'product';
            // Update counts for the post's terms.
            foreach ((array) get_object_taxonomies($post_type) as $taxonomy) {
                $tt_ids = wc_get_object_terms($product->get_id(), $taxonomy, 'term_taxonomy_id');
                wp_update_term_count($tt_ids, $taxonomy);
            }
        }
    }