wc_recount_all_terms()
Recounts all terms for product categories and product tags.
No Hooks.
Returns
null. Nothing (null).
Usage
wc_recount_all_terms( $include_callback );
- $include_callback(true|false)
- True to update the standard term counts in addition to the product-specific counts, which will cause a lot more queries to run.
Default:true
Changelog
| Since 5.2 | Introduced. |
wc_recount_all_terms() wc recount all terms code WC 10.6.2
function wc_recount_all_terms( bool $include_callback = true ) {
$product_cats = get_terms(
array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'fields' => 'id=>parent',
)
);
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), $include_callback, false );
$product_tags = get_terms(
array(
'taxonomy' => 'product_tag',
'hide_empty' => false,
'fields' => 'id=>parent',
)
);
_wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), $include_callback, false );
}