Automattic\WooCommerce\Database\Migrations
MigrationHelper::migrate_country_states_for_store_location()
Migrate the state code for the store location.
Метод класса: MigrationHelper{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = MigrationHelper::migrate_country_states_for_store_location( $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_store_location() MigrationHelper::migrate country states for store location WC 9.7.1
private static function migrate_country_states_for_store_location( string $country_code, array $old_to_new_states_mapping ): void { $store_location = get_option( 'woocommerce_default_country', '' ); if ( StringUtil::starts_with( $store_location, "{$country_code}:" ) ) { $old_location_code = substr( $store_location, 3 ); if ( array_key_exists( $old_location_code, $old_to_new_states_mapping ) ) { $new_location_code = "{$country_code}:{$old_to_new_states_mapping[$old_location_code]}"; update_option( 'woocommerce_default_country', $new_location_code ); } } }