Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::get_country_data()
Gets country codes, names, states, and locale information.
Method of the class: CartCheckoutUtils{}
No Hooks.
Return
Array
.
Usage
$result = CartCheckoutUtils::get_country_data();
CartCheckoutUtils::get_country_data() CartCheckoutUtils::get country data code WC 9.4.2
public static function get_country_data() { $billing_countries = WC()->countries->get_allowed_countries(); $shipping_countries = WC()->countries->get_shipping_countries(); $country_locales = wc()->countries->get_country_locale(); $country_states = wc()->countries->get_states(); $all_countries = self::deep_sort_with_accents( array_unique( array_merge( $billing_countries, $shipping_countries ) ) ); $country_data = []; foreach ( array_keys( $all_countries ) as $country_code ) { $country_data[ $country_code ] = [ 'allowBilling' => isset( $billing_countries[ $country_code ] ), 'allowShipping' => isset( $shipping_countries[ $country_code ] ), 'states' => $country_states[ $country_code ] ?? [], 'locale' => $country_locales[ $country_code ] ?? [], ]; } return $country_data; }