wc_clear_term_product_ids

When a post is updated and terms recounted (called by _update_post_term_count), clear the ids.

Description

wc_clear_term_product_ids( (int) $object_id, (array) $terms, (array) $tt_ids, (string) $taxonomy, (bool) $append, (array) $old_tt_ids ); 

Parameters (6)

0. $object_id (int)
The object id.
1. $terms (array)
An array of object terms.
2. $tt_ids (array)
An array of term taxonomy IDs.
3. $taxonomy (string)
Taxonomy slug.
4. $append (bool)
Whether to append new terms to the old terms.
5. $old_tt_ids (array)
Old array of term taxonomy IDs.

Usage

  1. if ( !function_exists( 'wc_clear_term_product_ids' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php'; 
  3.  
  4. // The object id. 
  5. $object_id = -1; 
  6.  
  7. // An array of object terms. 
  8. $terms = array(); 
  9.  
  10. // An array of term taxonomy IDs. 
  11. $tt_ids = array(); 
  12.  
  13. // Taxonomy slug. 
  14. $taxonomy = ''; 
  15.  
  16. // Whether to append new terms to the old terms. 
  17. $append = true; 
  18.  
  19. // Old array of term taxonomy IDs. 
  20. $old_tt_ids = array(); 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = wc_clear_term_product_ids($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); 
  24.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-term-functions.php  
  1. function wc_clear_term_product_ids( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { 
  2. foreach ( $old_tt_ids as $term_id ) { 
  3. delete_woocommerce_term_meta( $term_id, 'product_ids' ); 
  4. foreach ( $tt_ids as $term_id ) { 
  5. delete_woocommerce_term_meta( $term_id, 'product_ids' );