wc_taxonomy_metadata_migrate_data()WC 1.0

Migrate data from WC term meta to WP term meta.

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).

Хуков нет.

Возвращает

null. Ничего.

Использование

wc_taxonomy_metadata_migrate_data( $wp_db_version, $wp_current_db_version );
$wp_db_version(строка) (обязательный)
The new $wp_db_version.
$wp_current_db_version(строка) (обязательный)
The old (current) $wp_db_version.

Код wc_taxonomy_metadata_migrate_data() WC 6.4.1

function wc_taxonomy_metadata_migrate_data( $wp_db_version, $wp_current_db_version ) {
	if ( $wp_db_version >= 34370 && $wp_current_db_version < 34370 ) {
		global $wpdb;
		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;" ) ) {
			$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_termmeta" );
		}
	}
}