wc_taxonomy_metadata_migrate_data

Migrate data from WC term meta to WP term meta.

Description

wc_taxonomy_metadata_migrate_data( (string) $wp_db_version, (string) $wp_current_db_version ); 

When the database is updated to support term meta, migrate WC term meta data across. We do this when the new version is >= 34370, and the old version is < 34370 (34370 is when term meta table was added).

Parameters (2)

0. $wp_db_version (string)
The new $wp_db_version.
1. $wp_current_db_version (string)
The old (current) $wp_db_version.

Usage

  1. if ( !function_exists( 'wc_taxonomy_metadata_migrate_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php'; 
  3.  
  4. // The new $wp_db_version. 
  5. $wp_db_version = ''; 
  6.  
  7. // The old (current) $wp_db_version. 
  8. $wp_current_db_version = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_taxonomy_metadata_migrate_data($wp_db_version, $wp_current_db_version); 
  12.  

Defined (1)

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

/includes/wc-term-functions.php  
  1. function wc_taxonomy_metadata_migrate_data( $wp_db_version, $wp_current_db_version ) { 
  2. if ( $wp_db_version >= 34370 && $wp_current_db_version < 34370 ) { 
  3. global $wpdb; 
  4. if ( $wpdb->query( "INSERT INTO {$wpdb->termmeta} ( term_id, meta_key, meta_value ) SELECT woocommerce_term_id, meta_key, meta_value FROM {$wpdb->prefix}woocommerce_termmeta;" ) ) { 
  5. $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_termmeta" );