Automattic\WooCommerce\Internal\Admin\Settings

Payments::set_countrypublicWC 1.0

Set the business location country for the Payments settings.

Method of the class: Payments{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Payments = new Payments();
$Payments->set_country( $location ): bool;
$location(string) (required)
The country code. This should be a ISO 3166-1 alpha-2 country code.

Payments::set_country() code WC 9.9.3

public function set_country( string $location ): bool {
	$previous_country = $this->get_country();

	$user_payments_nox_profile = get_user_meta( get_current_user_id(), self::PAYMENTS_NOX_PROFILE_KEY, true );

	if ( empty( $user_payments_nox_profile ) ) {
		$user_payments_nox_profile = array();
	} else {
		$user_payments_nox_profile = maybe_unserialize( $user_payments_nox_profile );
	}
	$user_payments_nox_profile['business_country_code'] = $location;

	$result = false !== update_user_meta( get_current_user_id(), self::PAYMENTS_NOX_PROFILE_KEY, $user_payments_nox_profile );

	if ( $result && $previous_country !== $location ) {
		// Record an event that the business location (registration country code) was changed.
		$this->record_event(
			'business_location_update',
			array(
				'business_country'          => $location,
				'previous_business_country' => $previous_country,
			)
		);
	}

	return $result;
}