Automattic\WooCommerce\Database\Migrations

MigrationHelper::migrate_country_states_for_tax_rates()private staticWC 1.0

Migrate state codes in the tax rates table.

Метод класса: MigrationHelper{}

Хуков нет.

Возвращает

null. Ничего.

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

$result = MigrationHelper::migrate_country_states_for_tax_rates( $country_code, $old_to_new_states_mapping ): void;
$country_code(строка) (обязательный)
The country that has the states for which the migration is needed.
$old_to_new_states_mapping(массив) (обязательный)
An associative array where keys are the old state codes and values are the new state codes.

Код MigrationHelper::migrate_country_states_for_tax_rates() WC 7.3.0

private static function migrate_country_states_for_tax_rates( string $country_code, array $old_to_new_states_mapping ): void {
	global $wpdb;

	foreach ( $old_to_new_states_mapping as $old_state_code => $new_state_code ) {
		$wpdb->query(
			$wpdb->prepare(
				"UPDATE {$wpdb->prefix}woocommerce_tax_rates SET tax_rate_state=%s WHERE tax_rate_country=%s AND tax_rate_state=%s",
				$new_state_code,
				$country_code,
				$old_state_code
			)
		);
	}
}